// :where() keeps these at zero specificity so consumer overrides win in every
// theme; see the note in _colors.scss.
:where(:root) {
  --shadow-none: none;
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);

  // Composable top-edge highlight appended to every dark-mode shadow so elevated
  // surfaces catch light along their top edge; a no-op in light mode.
  --shadow-edge-highlight: 0 0 #0000;

  // Bevel: paired inset highlight (top) + shadow (bottom) for a raised look;
  // compose with --shadow-* for an ambient drop.
  --shadow-bevel:
    inset 0 1px 1px rgba(255, 255, 255, 0.85), inset 0 -1px 1.5px rgba(0, 0, 0, 0.25);
  --shadow-bevel-strong:
    inset 0 1.5px 2px rgba(255, 255, 255, 0.9), inset 0 -2px 3px rgba(0, 0, 0, 0.3);

  // Well: inverse of bevel (inset shadow top, highlight bottom) for a recessed look
  --shadow-well:
    inset 0 1px 1.5px rgba(0, 0, 0, 0.3), inset 0 -1px 0.5px rgba(255, 255, 255, 0.5);
  --shadow-well-strong:
    inset 0 2px 3px rgba(0, 0, 0, 0.4), inset 0 -1.5px 1px rgba(255, 255, 255, 0.55);

  --shadow-focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.45);
  --shadow-focus-ring-error: 0 0 0 3px var(--color-error-200);
  --shadow-focus-ring-success: 0 0 0 3px var(--color-success-200);

  --z-index-base: 0;
  --z-index-raised: 10;
  --z-index-dropdown: 100;
  --z-index-sticky: 200;
  --z-index-overlay: 300;
  --z-index-modal: 400;
  --z-index-popover: 500;
  --z-index-toast: 600;
  --z-index-tooltip: 700;
}

// Dark mode: a drop shadow is the absence of light, so it stays black (deeper
// than light mode); a white "shadow" reads as a glow and looks wrong. Elevation
// is carried instead by the lifted surface tone plus a hairline top highlight
// that catches light, appended to every level via --shadow-edge-highlight.
@mixin dark-elevation-tokens {
  --shadow-edge-highlight: inset 0 1px 0 0 rgba(255, 255, 255, 0.06);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4), var(--shadow-edge-highlight);
  --shadow-sm:
    0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px -1px rgba(0, 0, 0, 0.4),
    var(--shadow-edge-highlight);
  --shadow-md:
    0 4px 8px -2px rgba(0, 0, 0, 0.55), 0 2px 4px -2px rgba(0, 0, 0, 0.4),
    var(--shadow-edge-highlight);
  --shadow-lg:
    0 12px 20px -4px rgba(0, 0, 0, 0.6), 0 4px 8px -4px rgba(0, 0, 0, 0.45),
    var(--shadow-edge-highlight);
  --shadow-xl:
    0 20px 28px -6px rgba(0, 0, 0, 0.65), 0 8px 12px -6px rgba(0, 0, 0, 0.5),
    var(--shadow-edge-highlight);
  --shadow-2xl: 0 28px 50px -12px rgba(0, 0, 0, 0.75), var(--shadow-edge-highlight);

  // On a dark surface a bright highlight reads as a halo, so drop the highlight
  // alpha and raise the shadow alpha to keep the relief without glowing.
  --shadow-bevel:
    inset 0 1px 1px rgba(255, 255, 255, 0.18), inset 0 -1px 1.5px rgba(0, 0, 0, 0.6);
  --shadow-bevel-strong:
    inset 0 1.5px 2px rgba(255, 255, 255, 0.22), inset 0 -2px 3px rgba(0, 0, 0, 0.7);
  --shadow-well:
    inset 0 1px 1.5px rgba(0, 0, 0, 0.55), inset 0 -1px 0.5px rgba(255, 255, 255, 0.08);
  --shadow-well-strong:
    inset 0 2px 3px rgba(0, 0, 0, 0.7), inset 0 -1.5px 1px rgba(255, 255, 255, 0.12);
}

@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme='light'])) {
    @include dark-elevation-tokens;
  }
}

:where(:root[data-theme='dark']) {
  @include dark-elevation-tokens;
}
