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


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


/**
 * @prop --mds-tab-item-hover-background: Background color when hovering a tab item.
 * @prop --mds-tab-item-selected-background: Background color of a selected tab item.
 * @prop --mds-tab-item-selected-shadow: Shadow of a selected tab item.
 * @prop --mds-tab-item-default-background: Default background color of a tab item.
 * @prop --mds-tab-item-default-shadow: Default shadow of a tab item.
 */

/*
  No css/mds-tab-item-property.css on purpose. The backgrounds and colours here are only
  set under a conditional :host([animation='slide']) or a pref-* guard, or are not set at
  all, so a document-level registration would start supplying an initial-value in every
  state that has none today. --mds-tab-item-radius is out too: its default is the
  CSS-wide keyword inherit, which an initial-value cannot express. See
  projects/styles/scripts/properties.ts for how the registrations are collected.
*/

/* Not supported
@property --mds-tab-item-selected-shadow {
  inherits: false;
  initial-value: none;
  syntax: "<box-shadow>";
}

@property --mds-tab-item-default-shadow {
  inherits: false;
  initial-value: none;
  syntax: "<box-shadow>";
}
*/

:host {
  --mds-tab-item-selected-shadow: inherit;
  --mds-tab-item-radius: inherit;

  corner-shape: var(--magma-corner-shape, squircle);
  cursor: pointer;
  display: flex;
}

:host([animation='slide']) {
  --mds-tab-item-hover-background: transparent;
  --mds-tab-item-selected-background: transparent;
  --mds-tab-item-selected-shadow: none;
  --mds-tab-item-default-background: transparent;
  --mds-tab-item-default-shadow: none;
  --mds-tab-item-hover-shadow: none;
}

.button {
  --mds-button-background: var(--mds-tab-item-default-background);
  --mds-button-color: var(--mds-tab-item-default-color);
  --mds-button-radius: var(--mds-tab-item-radius);
  --mds-button-border-default-opacity: 0;
  --mds-button-corner-shape: var(--mds-tab-item-corner-shape, var(--magma-corner-shape, squircle));

  aspect-ratio: initial;
  box-shadow: var(--mds-tab-item-default-shadow, none);
  flex-grow: 1;
}

/* without a hover shadow of its own, a hovered item keeps the default one */

.button:hover {
  --mds-button-background: var(--mds-tab-item-hover-background);
  --mds-button-color: var(--mds-tab-item-hover-color);

  box-shadow: var(--mds-tab-item-hover-shadow, var(--mds-tab-item-default-shadow, none));
}

.button.selected,
.button.selected:hover {
  --mds-button-background: var(--mds-tab-item-selected-background);
  --mds-button-color: var(--mds-tab-item-selected-color);

  box-shadow: var(--mds-tab-item-selected-shadow);
  pointer-events: none;
}

:host([disabled]) {
  pointer-events: none;
}

:host([direction='vertical']) {
  width: 100%;
}

:host([direction='vertical']) .button {
  justify-content: start;
}

/* Theme preference. The component takes its colours from semantic roles that
 * flip per mode at :root (spec 6.1-6.3) and inherit into the shadow DOM, so it
 * needs no per-mode dark refinement. The former dark override (a ramp step
 * re-set to lift the colour off the old flat-black canvas) is intentionally gone. */

/* 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. */

:host([pref-contrast='more']) {
  --mds-tab-item-selected-color: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
  --mds-tab-item-selected-shadow: var(--shadow-ring-strong-2, 0 0 0 2px rgb(var(--tone-neutral-01, 5 5 5) / 0.6));
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system']),
  :host(:not([pref-contrast])) {
    --mds-tab-item-selected-color: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
    --mds-tab-item-selected-shadow: var(--shadow-ring-strong-2, 0 0 0 2px rgb(var(--tone-neutral-01, 5 5 5) / 0.6));
  }
}

