/* Starling design tokens: Material 3 color roles, type, shape, elevation and
   motion (docs/DESIGN.md sections 4 and 5). Every value app.css uses comes
   from here. The 27 replaceable roles may be overridden inline on <html> by
   the phone's own palette; error, ok, warn and scrim never are. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Roboto Mono", "Droid Sans Mono", Menlo, Consolas, monospace;

  --type-display-small: 400 2.25rem/2.75rem var(--font);
  --type-headline-medium: 400 1.75rem/2.25rem var(--font);
  --type-headline-small: 400 1.5rem/2rem var(--font);
  --type-title-large: 400 1.375rem/1.75rem var(--font);
  --type-title-medium: 500 1rem/1.5rem var(--font);
  --type-title-small: 500 0.875rem/1.25rem var(--font);
  --type-body-large: 400 1rem/1.5rem var(--font);
  --type-body-medium: 400 0.875rem/1.25rem var(--font);
  --type-body-small: 400 0.75rem/1rem var(--font);
  --type-label-large: 500 0.875rem/1.25rem var(--font);
  --type-label-medium: 500 0.75rem/1rem var(--font);
  --type-label-small: 500 0.6875rem/1rem var(--font);

  --track-display-small: 0;
  --track-headline-medium: 0;
  --track-headline-small: 0;
  --track-title-large: 0;
  --track-title-medium: 0.009em;
  --track-title-small: 0.007em;
  --track-body-large: 0.031em;
  --track-body-medium: 0.018em;
  --track-body-small: 0.033em;
  --track-label-large: 0.007em;
  --track-label-medium: 0.042em;
  --track-label-small: 0.045em;

  --shape-xs: 4px;
  --shape-sm: 8px;
  --shape-md: 12px;
  --shape-lg: 16px;
  --shape-xl: 28px;
  --shape-full: 9999px;

  --elev-1: 0 1px 2px rgb(0 0 0 / 0.3), 0 1px 3px 1px rgb(0 0 0 / 0.15);
  --elev-2: 0 1px 2px rgb(0 0 0 / 0.3), 0 2px 6px 2px rgb(0 0 0 / 0.15);
  --elev-3: 0 1px 3px rgb(0 0 0 / 0.3), 0 4px 8px 3px rgb(0 0 0 / 0.15);

  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized-decel: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-emphasized-accel: cubic-bezier(0.3, 0, 0.8, 0.15);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --dur-short2: 100ms;
  --dur-short3: 150ms;
  --dur-short4: 200ms;
  --dur-medium1: 250ms;
  --dur-medium2: 300ms;
  --dur-medium4: 400ms;

  --state-hover: 0.08;
  --state-focus: 0.1;
  --state-press: 0.1;
  --state-drag: 0.16;

  --safe-top: max(env(safe-area-inset-top, 0px), var(--inset-top, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--inset-right, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--inset-left, 0px));
  /* The height of a navigation bar with buttons on it, from the shell. 0 with the gesture handle. */
  --nav-bar: 0px;

  /* A QR code is read by a camera, so its paper stays white in both themes. */
  --qr-paper: #ffffff;
}

/* Dark: the fallback palette seeded from Starling teal. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --md-primary: #53dbc9;
  --md-on-primary: #003731;
  --md-primary-container: #005048;
  --md-on-primary-container: #9ef2e5;
  --md-secondary: #b1ccc6;
  --md-on-secondary: #1c3531;
  --md-secondary-container: #334b47;
  --md-on-secondary-container: #cce8e2;
  --md-tertiary: #adc8e5;
  --md-on-tertiary: #143349;
  --md-tertiary-container: #2d4961;
  --md-on-tertiary-container: #cbe5ff;
  --md-surface: #0e1513;
  --md-surface-dim: #0e1513;
  --md-surface-bright: #343b39;
  --md-surface-container-lowest: #090f0e;
  --md-surface-container-low: #161d1c;
  --md-surface-container: #1a211f;
  --md-surface-container-high: #252b2a;
  --md-surface-container-highest: #2f3634;
  --md-on-surface: #dde4e1;
  --md-on-surface-variant: #bec9c5;
  --md-outline: #899390;
  --md-outline-variant: #3f4946;
  --md-inverse-surface: #dde4e1;
  --md-inverse-on-surface: #2b3230;
  --md-inverse-primary: #006a60;

  --md-error: #ffb4ab;
  --md-on-error: #690005;
  --md-error-container: #93000a;
  --md-on-error-container: #ffdad6;
  --md-ok: #7fda9a;
  --md-on-ok: #00391a;
  --md-ok-container: #00522a;
  --md-on-ok-container: #a3f5b8;
  --md-warn: #f2c04a;
  --md-on-warn: #402d00;
  --md-warn-container: #5c4300;
  --md-on-warn-container: #ffdf9e;
  --md-scrim: #000000;
  --md-shadow: #000000;

  --m-container-l: 0.36;
  --m-container-c: 0.07;
  --m-on-container-l: 0.92;
  --m-on-container-c: 0.05;
  --m-container-hsl: 38% 24%;
  --m-on-container-hsl: 60% 88%;
}

/* Light. */
:root[data-theme="light"] {
  color-scheme: light;

  --md-primary: #006a60;
  --md-on-primary: #ffffff;
  --md-primary-container: #9ef2e5;
  --md-on-primary-container: #00201c;
  --md-secondary: #4a635f;
  --md-on-secondary: #ffffff;
  --md-secondary-container: #cce8e2;
  --md-on-secondary-container: #06201c;
  --md-tertiary: #456179;
  --md-on-tertiary: #ffffff;
  --md-tertiary-container: #cbe5ff;
  --md-on-tertiary-container: #001d31;
  --md-surface: #f4fbf8;
  --md-surface-dim: #d5dbd9;
  --md-surface-bright: #f4fbf8;
  --md-surface-container-lowest: #ffffff;
  --md-surface-container-low: #eef5f2;
  --md-surface-container: #e9efec;
  --md-surface-container-high: #e3e9e7;
  --md-surface-container-highest: #dde4e1;
  --md-on-surface: #161d1c;
  --md-on-surface-variant: #3f4946;
  --md-outline: #6f7977;
  --md-outline-variant: #bec9c5;
  --md-inverse-surface: #2b3230;
  --md-inverse-on-surface: #ecf2ef;
  --md-inverse-primary: #53dbc9;

  --md-error: #ba1a1a;
  --md-on-error: #ffffff;
  --md-error-container: #ffdad6;
  --md-on-error-container: #410002;
  --md-ok: #1b6c3a;
  --md-on-ok: #ffffff;
  --md-ok-container: #a3f5b8;
  --md-on-ok-container: #00210c;
  --md-warn: #7a5900;
  --md-on-warn: #ffffff;
  --md-warn-container: #ffdf9e;
  --md-on-warn-container: #261a00;
  --md-scrim: #000000;
  --md-shadow: #000000;

  --m-container-l: 0.9;
  --m-container-c: 0.06;
  --m-on-container-l: 0.3;
  --m-on-container-c: 0.08;
  --m-container-hsl: 60% 86%;
  --m-on-container-hsl: 55% 22%;
}

/* A page that never sets data-theme (the help viewer, the privacy page, and
   this one before its script runs) follows the system. Same values as the
   light block above. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;

    --md-primary: #006a60;
    --md-on-primary: #ffffff;
    --md-primary-container: #9ef2e5;
    --md-on-primary-container: #00201c;
    --md-secondary: #4a635f;
    --md-on-secondary: #ffffff;
    --md-secondary-container: #cce8e2;
    --md-on-secondary-container: #06201c;
    --md-tertiary: #456179;
    --md-on-tertiary: #ffffff;
    --md-tertiary-container: #cbe5ff;
    --md-on-tertiary-container: #001d31;
    --md-surface: #f4fbf8;
    --md-surface-dim: #d5dbd9;
    --md-surface-bright: #f4fbf8;
    --md-surface-container-lowest: #ffffff;
    --md-surface-container-low: #eef5f2;
    --md-surface-container: #e9efec;
    --md-surface-container-high: #e3e9e7;
    --md-surface-container-highest: #dde4e1;
    --md-on-surface: #161d1c;
    --md-on-surface-variant: #3f4946;
    --md-outline: #6f7977;
    --md-outline-variant: #bec9c5;
    --md-inverse-surface: #2b3230;
    --md-inverse-on-surface: #ecf2ef;
    --md-inverse-primary: #53dbc9;

    --md-error: #ba1a1a;
    --md-on-error: #ffffff;
    --md-error-container: #ffdad6;
    --md-on-error-container: #410002;
    --md-ok: #1b6c3a;
    --md-on-ok: #ffffff;
    --md-ok-container: #a3f5b8;
    --md-on-ok-container: #00210c;
    --md-warn: #7a5900;
    --md-on-warn: #ffffff;
    --md-warn-container: #ffdf9e;
    --md-on-warn-container: #261a00;
    --md-scrim: #000000;
    --md-shadow: #000000;

    --m-container-l: 0.9;
    --m-container-c: 0.06;
    --m-on-container-l: 0.3;
    --m-on-container-c: 0.08;
    --m-container-hsl: 60% 86%;
    --m-on-container-hsl: 55% 22%;
  }
}

/* A member's own color, from their member id through --m-hue. Not a theme
   color: it never follows the wallpaper. The hsl() lines stand where oklch()
   is not understood. */
.ava,
.mk,
.member-card,
.focus-card {
  --m-container: hsl(var(--m-hue, 170) var(--m-container-hsl));
  --m-on-container: hsl(var(--m-hue, 170) var(--m-on-container-hsl));
  --m-accent: hsl(var(--m-hue, 170) 55% 50%);
}

@supports (color: oklch(0.5 0.1 180)) {
  .ava,
  .mk,
  .member-card,
  .focus-card {
    --m-container: oklch(var(--m-container-l) var(--m-container-c) var(--m-hue, 170));
    --m-on-container: oklch(var(--m-on-container-l) var(--m-on-container-c) var(--m-hue, 170));
    --m-accent: oklch(0.62 0.14 var(--m-hue, 170));
  }
}
