/* Interface style shared by the map pages and the shape editor (docs/AVALANCHE_UI_DESIGN.md, direction B).
   Mapbox Assembly v2.1.0 (loaded before this file) gives the reset, Open Sans, text sizes, fields and icons; this file
   adds what Assembly does not have: the look of the Mapbox map controls (white surface, 4 px corners, a thin outline,
   square grouped buttons 29 px high), colour tokens for light and dark, and no accent colour.
   Dark mode follows the device; <html class="ui-light"> keeps a page light (the embed, which sits in light blog posts). */

:root {
  --ui-page: #f4f5f6;
  --ui-surface: #fff;
  --ui-bar: #fff;
  --ui-text: #333;
  --ui-muted: #5f6569;
  --ui-line: #ddd;
  --ui-ring: rgba(0, 0, 0, 0.1);
  --ui-hover: #f4f5f6;
  --ui-selected: #f0f1f2;
  --ui-link: #0f71fa;
  --ui-dot: #ccd1d6;
  --ui-dot-now: #4d5255;
  --ui-warning: #a85a00;
  --ui-error: #c0392b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not(.ui-light) {
    --ui-page: #111517;
    --ui-surface: #1f2427;
    --ui-bar: #1a1f22;
    --ui-text: #e6e8ea;
    --ui-muted: #9aa3ab;
    --ui-line: #3a4146;
    --ui-ring: rgba(255, 255, 255, 0.14);
    --ui-hover: #2a3034;
    --ui-selected: #39414a;
    --ui-link: #7fb8ff;
    --ui-dot: #4a535b;
    --ui-dot-now: #c9ced2;
    --ui-warning: #f5c36b;
    --ui-error: #ff8a7a;
    color-scheme: dark;
  }
}

/* A page that stays light in dark mode: the same values as :root above. */
:root.ui-light {
  --ui-page: #f4f5f6;
  --ui-surface: #fff;
  --ui-bar: #fff;
  --ui-text: #333;
  --ui-muted: #5f6569;
  --ui-line: #ddd;
  --ui-ring: rgba(0, 0, 0, 0.1);
  --ui-hover: #f4f5f6;
  --ui-selected: #f0f1f2;
  --ui-link: #0f71fa;
  --ui-dot: #ccd1d6;
  --ui-dot-now: #4d5255;
  --ui-warning: #a85a00;
  --ui-error: #c0392b;
  color-scheme: light;
}

body { color: var(--ui-text); font-family: 'Open Sans', sans-serif; }
.ui-muted { color: var(--ui-muted); }
.ui-link, .ui-surface a { color: var(--ui-link); }
.ui-link:hover, .ui-surface a:hover { text-decoration: underline; }

/* A panel over the map, like the map controls. */
.ui-surface { background: var(--ui-surface); color: var(--ui-text); border-radius: 4px; box-shadow: 0 0 0 2px var(--ui-ring); }

/* Buttons in a group: square, 29 px high, divided by a thin line; one button alone is a group of one. */
.ui-group { display: inline-flex; flex: none; align-items: stretch; background: var(--ui-surface); border-radius: 4px; box-shadow: 0 0 0 2px var(--ui-ring); overflow: hidden; }
.ui-group > button, .ui-group > a { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 29px; min-width: 29px; padding: 0 10px; font-size: 12px; line-height: 1; white-space: nowrap; color: var(--ui-text); cursor: pointer; }
.ui-group > :is(button, a) + :is(button, a) { border-left: 1px solid var(--ui-line); }
.ui-group > :is(button, a[href]):hover:not(:disabled) { background: var(--ui-hover); }
.ui-group > button[aria-pressed="true"], .ui-group > .is-selected { background: var(--ui-selected); font-weight: 700; }
.ui-group > button:disabled, .ui-group > a:not([href]) { opacity: 0.4; cursor: default; }
.ui-group > a { text-decoration: none; }
.ui-group > :is(button, a):focus-visible { outline: 2px solid var(--ui-text); outline-offset: -2px; }
.ui-group > button.ui-icon-only { padding: 0; width: 29px; }
.ui-group .icon { flex: none; width: 18px; height: 18px; }

/* Fields: Assembly's own fields do not follow dark mode in the CDN build, so they take the tokens here. */
.ui-field { box-sizing: border-box; height: 29px; padding: 0 8px; border: 1px solid var(--ui-line); border-radius: 4px; background: var(--ui-surface); color: var(--ui-text); font: inherit; font-size: 13px; }
select.ui-field { padding-right: 4px; cursor: pointer; }
textarea.ui-field { height: auto; padding: 8px; }
.ui-field:focus-visible { outline: 2px solid var(--ui-text); outline-offset: -1px; }
.ui-surface input[type="checkbox"] { accent-color: var(--ui-dot-now); }
.ui-warning { color: var(--ui-warning); }
.ui-error { color: var(--ui-error); }

/* Mapbox popups keep Mapbox's own look (U9): their box is white in dark mode too, so the text stays dark, and the
   close button gets back the padding Assembly's reset takes from it. */
.mapboxgl-popup-content { color: #333; }
.mapboxgl-popup-close-button { padding: 1px 6px; text-align: center; }
