/* ==========================================================================
   Painted areas — .theme-<color>-<strength> gives any element a colored
   background at a strength, and makes everything inside readable on it.

   <section class="theme-green-soft">…</section>
   <aside class="theme-indigo-deep">…</aside>

   Strengths: -subtle · -soft · -fill (the default look) · -solid · -vivid · -deep
   (plain .theme-green only colors what's inside — it doesn't paint a background).

   Inside, text levels, lines and neutral surfaces follow the area's text color;
   accents (progress, switches, checkboxes, radios, sliders) use the text color too,
   with the area's color on top — so nothing ever disappears into the background.
   Colored cards and alerts work the same way. On -solid and -vivid, whose text is only just
   above 4.5:1, muted text keeps the full text color so it stays readable.
   ========================================================================== */

/*@surfaces subtle*/ { --mo-surface-bg: var(--mo-theme-subtle); --mo-surface-color: var(--mo-theme-subtle-text); --mo-surface-mark: var(--mo-check-on-text); --mo-surface-dash: var(--mo-dash-on-text); }
/*@surfaces soft*/   { --mo-surface-bg: var(--mo-theme-soft);   --mo-surface-color: var(--mo-theme-soft-text);   --mo-surface-mark: var(--mo-check-on-text); --mo-surface-dash: var(--mo-dash-on-text); }
/*@surfaces fill*/   { --mo-surface-bg: var(--mo-theme-fill);   --mo-surface-color: var(--mo-theme-fill-text);   --mo-surface-mark: var(--mo-theme-fill-mark);  --mo-surface-dash: var(--mo-theme-fill-dash); }
/*@surfaces solid*/  { --mo-surface-muted: 100%; --mo-surface-bg: var(--mo-theme-solid);  --mo-surface-color: var(--mo-theme-solid-text);  --mo-surface-mark: var(--mo-theme-solid-mark); --mo-surface-dash: var(--mo-theme-solid-dash); }
/*@surfaces vivid*/  { --mo-surface-muted: 100%; --mo-surface-bg: var(--mo-theme-vivid);  --mo-surface-color: var(--mo-theme-vivid-text);  --mo-surface-mark: var(--mo-theme-vivid-mark); --mo-surface-dash: var(--mo-theme-vivid-dash); }
/*@surfaces deep*/   { --mo-surface-bg: var(--mo-theme-deep);   --mo-surface-color: var(--mo-theme-deep-text);   --mo-surface-mark: var(--mo-theme-deep-mark);  --mo-surface-dash: var(--mo-theme-deep-dash); }

:where(/*@surfaces*/) {
  color: var(--mo-surface-color);
  background-color: var(--mo-surface-bg);
  /* text levels and lines */
  --mo-fg-body: var(--mo-surface-color);
  --mo-fg-2: color-mix(in oklab, var(--mo-surface-color) 92%, transparent);
  --mo-fg-3: color-mix(in oklab, var(--mo-surface-color) var(--mo-surface-muted, 85%), transparent);   /* still 4.5:1 for small text */
  --mo-border-color: color-mix(in oklab, var(--mo-surface-color) 16%, transparent);
  --mo-border-color-strong: color-mix(in oklab, var(--mo-surface-color) 32%, transparent);
  /* neutral surfaces (plain buttons, wells, tags) become see-through tints of the text color */
  --mo-bg-1: color-mix(in oklab, var(--mo-surface-color) 6%, transparent);
  --mo-bg-2: color-mix(in oklab, var(--mo-surface-color) 10%, transparent);
  --mo-bg-3: color-mix(in oklab, var(--mo-surface-color) 14%, transparent);
  /* accents: the text color, with the area's color on top */
  --mo-accent: var(--mo-surface-color);
  --mo-accent-contrast: var(--mo-surface-bg);
  --mo-track: color-mix(in oklab, var(--mo-surface-color) 22%, transparent);
  --mo-check-mark: var(--mo-surface-mark);
  --mo-check-dash: var(--mo-surface-dash);
}
:where(/*@surfaces*/) a:not([class]) { color: inherit; text-decoration-color: color-mix(in oklab, currentColor 50%, transparent); }

/* A strong button with no color of its own (btn-solid / -vivid / -deep) on a strong area would be
   the area's own color. There it's drawn like the accents: the area's text color, with the area's
   color as its text. (Buttons with a color class — btn-red — keep theirs.) */
:where(/*@surfaces fill*/, /*@surfaces solid*/, /*@surfaces vivid*/, /*@surfaces deep*/,
  :is(/*@colors card*/, .card-solid, .card-vivid, .card-deep):not(.card-subtle, .card-soft),
  .card:where(/*@themes*/):not(.card-subtle, .card-soft))
  :is(.btn-solid, .btn-vivid, .btn-deep):not(:is(/*@colors btn*/)) {
  --mo-btn-bg: var(--mo-accent);
  --mo-btn-color: var(--mo-accent-contrast);
  --mo-btn-border: transparent;
  --mo-btn-hover-bg: color-mix(in oklab, var(--mo-accent) 86%, var(--mo-accent-contrast));
  --mo-btn-hover-color: var(--mo-accent-contrast);
  --mo-btn-active-bg: color-mix(in oklab, var(--mo-accent) 76%, var(--mo-accent-contrast));
}
/* …and an outline / ghost / link button with no color of its own would be the area's color on
   the area's color — unreadable. There it takes the area's text color instead. */
:where(/*@surfaces fill*/, /*@surfaces solid*/, /*@surfaces vivid*/, /*@surfaces deep*/,
  :is(/*@colors card*/, .card-solid, .card-vivid, .card-deep):not(.card-subtle, .card-soft),
  .card:where(/*@themes*/):not(.card-subtle, .card-soft))
  :is(.btn-outline, .btn-ghost, .btn-link):not(:is(/*@colors btn*/)) {
  --mo-btn-color: var(--mo-accent);
  --mo-btn-hover-color: var(--mo-accent);
  --mo-btn-hover-bg: color-mix(in oklab, var(--mo-accent) 12%, transparent);
  --mo-btn-active-bg: color-mix(in oklab, var(--mo-accent) 20%, transparent);
}
:where(/*@surfaces fill*/, /*@surfaces solid*/, /*@surfaces vivid*/, /*@surfaces deep*/,
  :is(/*@colors card*/, .card-solid, .card-vivid, .card-deep):not(.card-subtle, .card-soft),
  .card:where(/*@themes*/):not(.card-subtle, .card-soft))
  .btn-link:not(:is(/*@colors btn*/)) { --mo-btn-hover-bg: transparent; --mo-btn-active-bg: transparent; }
:where(/*@surfaces fill*/, /*@surfaces solid*/, /*@surfaces vivid*/, /*@surfaces deep*/,
  :is(/*@colors card*/, .card-solid, .card-vivid, .card-deep):not(.card-subtle, .card-soft),
  .card:where(/*@themes*/):not(.card-subtle, .card-soft))
  .btn-outline:not(:is(/*@colors btn*/)) { --mo-btn-border: color-mix(in oklab, var(--mo-accent) 50%, transparent); --mo-btn-hover-border: var(--mo-accent); }
