/* Brand tokens for Spectrum Web Components. Each Spectrum token that matters for the brand is set to
   the app's own colour variable (style.css :root), so one brand change reaches every Spectrum control.
   The overrides go on sp-theme, not :root, because sp-theme sets its own values on itself and wins over
   inherited ones. Light and dark both follow: the variables change with <html data-theme>.
   Verified against @spectrum-web-components/theme 1.12.6 (test/swc-brand.test.js). */
sp-theme {
  --spectrum-accent-background-color-default: var(--accent);
  --spectrum-accent-background-color-hover: var(--accent-hover);
  --spectrum-accent-content-color-default: var(--accent-ink);
  --spectrum-background-base-color: var(--bg-raise);
  --spectrum-background-layer-1-color: var(--bg);
  --spectrum-textfield-background-color: var(--bg-raise);
  --spectrum-alias-component-background-color-default: var(--bg-raise);
  --spectrum-neutral-content-color-default: var(--ink);
  --spectrum-neutral-subdued-content-color-default: var(--ink-soft);
  --spectrum-alias-border-color: var(--line-strong);
  --spectrum-disabled-background-color: var(--bg-sunk);
  --spectrum-negative-background-color-default: var(--alarm);
  --spectrum-positive-background-color-default: var(--ok);
  --spectrum-focus-indicator-color: var(--accent);
  --spectrum-sans-font-family-stack: var(--font-body);
}

/* Secondary buttons: the component sets its own colours on the element, so the override is set on it
   (the --mod-button-* variables are the component's supported override hook). */
sp-button[variant="secondary"] {
  --mod-button-background-color-default: var(--bg-raise);
  --mod-button-background-color-hover: var(--bg-sunk);
  --mod-button-background-color-down: var(--bg-sunk);
  --mod-button-border-color-default: var(--line-strong);
  --mod-button-content-color-default: var(--ink);
}

/* Accent buttons: the text takes the brand's accent ink (white in light, dark ink in dark), so text
   stays readable on the accent colour in both themes. */
sp-button[variant="accent"] {
  --mod-button-content-color-default: var(--accent-ink);
  --mod-button-content-color-hover: var(--accent-ink);
  --mod-button-content-color-focus: var(--accent-ink);
  --mod-button-content-color-down: var(--accent-ink);
}
sp-button.big { text-align: center; }
sp-button.big .sign-in-button-label { display: block; width: 100%; text-align: center; transform: translateY(9px); }

/* Icons inside Spectrum buttons (the SVG sits in the button's text slot): centre them on the label
   and keep a gap from the text, so icon and label line up in every button. */
sp-button svg, sp-action-button svg {
  display: inline-block;
  vertical-align: middle;
  flex: none;
  margin: -2px 6px 0 0;
}
sp-button svg:last-child:not(:first-child) { margin: -2px 0 0 6px; }

/* Shared Spectrum form fields follow the app's existing form rhythm. */
sp-textfield, sp-number-field { display: block; width: 100%; margin: 0 0 var(--space-3); }
.row > sp-textfield, .row > sp-number-field { flex: 1; width: auto; min-width: 0; margin: 0; }
sp-picker { display: block; width: 100%; min-width: 0; max-width: 100%; }
.package-unit-control > sp-picker { width: 0; }
sp-switch { display: block; margin: var(--space-3) 0; }
