/* ClayGen map viewer (map.js). Shared by the console and the support portal, which each dress it in their own
   colours by setting the --cgmap-* tokens (see "Map" in style.css and in portal/portal.css). The map's size is
   the box the page gives it: a height here, any width. */

.cgmap {
  position: relative; display: block; height: 320px; overflow: hidden; isolation: isolate;
  border: 1px solid var(--cgmap-line, #cbd0d7); border-radius: var(--cgmap-radius, 12px);
  background: var(--cgmap-ground, #e6e9ed); color: var(--cgmap-ink, #171b21);
  cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.cgmap.cgmap-dragging { cursor: grabbing; }
.cgmap:focus { outline: none; }
.cgmap:focus-visible { outline: 2px solid var(--cgmap-accent, #1695e8); outline-offset: 2px; border-radius: var(--cgmap-radius, 12px); box-shadow: none; }
.cgmap [hidden] { display: none !important; }
.cgmap-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* The tiles. A darker room gets a calmer map: the pictures themselves only come in daylight colours. */
.cgmap-layer { position: absolute; inset: 0; transform-origin: 0 0; filter: var(--cgmap-tiles, none); }
.cgmap-layer img {
  position: absolute; left: 0; top: 0; display: block; width: 256px; height: 256px; max-width: none;
  opacity: 0; transition: opacity .22s ease; pointer-events: none; -webkit-user-drag: none;
}
.cgmap-layer img.cgmap-in { opacity: 1; }
.cgmap-ghost { transition: transform .2s ease; }

/* The pin and the circle of uncertainty around it */
.cgmap-marks { position: absolute; inset: 0; pointer-events: none; }
.cgmap-accuracy {
  position: absolute; left: 0; top: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--cgmap-accent, #1695e8) 16%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--cgmap-accent, #1695e8) 62%, transparent);
}
.cgmap-pin { position: absolute; left: 0; top: 0; display: block; width: 30px; height: 38px; max-width: none; overflow: visible; filter: drop-shadow(0 2px 3px rgba(10, 16, 24, .38)); }
.cgmap-pin-body { fill: var(--cgmap-accent, #1695e8); stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.cgmap-pin-dot { fill: #fff; }
/* A last known place rather than a fresh one: the same marks in charcoal. */
.cgmap-last .cgmap-pin-body { fill: #4a535e; }
.cgmap-last .cgmap-accuracy { background: rgba(74, 83, 94, .14); border-color: rgba(74, 83, 94, .55); border-style: dashed; }
.cgmap-zooming .cgmap-pin, .cgmap-zooming .cgmap-accuracy { transition: transform .2s ease, width .2s ease, height .2s ease; }

/* Zoom and "back to the device" */
.cgmap-controls { position: absolute; top: 10px; right: 10px; display: grid; gap: 8px; }
.cgmap-zoom { display: grid; border-radius: 10px; box-shadow: 0 1px 4px rgba(10, 16, 24, .28); }
.cgmap .cgmap-btn {
  display: grid; place-items: center; width: 36px; height: 36px; margin: 0; padding: 0;
  border: 1px solid var(--cgmap-line, #cbd0d7); border-radius: 10px; background: var(--cgmap-surface, #fff); color: var(--cgmap-ink, #171b21);
  box-shadow: 0 1px 4px rgba(10, 16, 24, .28); cursor: pointer; transition: background-color .15s ease, color .15s ease;
}
.cgmap .cgmap-zoom .cgmap-btn { box-shadow: none; }
.cgmap .cgmap-zoom .cgmap-btn:first-child { border-radius: 10px 10px 0 0; }
.cgmap .cgmap-zoom .cgmap-btn:last-child { border-radius: 0 0 10px 10px; border-top: 0; }
.cgmap .cgmap-btn:hover:not(:disabled) { background: var(--cgmap-hover, #f1f3f5); color: var(--cgmap-accent, #1695e8); border-color: var(--cgmap-line, #cbd0d7); }
.cgmap .cgmap-btn:focus-visible { outline: 2px solid var(--cgmap-accent, #1695e8); outline-offset: 1px; box-shadow: none; position: relative; z-index: 1; }
.cgmap .cgmap-btn:disabled { opacity: 1; color: var(--cgmap-muted, #8b929c); cursor: default; }
.cgmap .cgmap-btn:disabled .cgmap-glyph { opacity: .45; }
.cgmap-glyph { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Scale, and where the pictures come from */
.cgmap-scale {
  position: absolute; left: 10px; bottom: 9px; min-width: 24px; padding: 0 5px 1px; pointer-events: none;
  border: 1.5px solid rgba(23, 27, 33, .7); border-top: 0; border-radius: 0 0 3px 3px;
  font: 600 10.5px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; color: #171b21; white-space: nowrap;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff; background: rgba(255, 255, 255, .45);
}
.cgmap-credit {
  position: absolute; right: 0; bottom: 0; padding: 1px 8px 2px; border-radius: 8px 0 0 0;
  background: rgba(255, 255, 255, .82); color: #2a3440; font: 400 11px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; text-decoration: none; cursor: pointer;
}
.cgmap a.cgmap-credit:hover { text-decoration: underline; color: #0b69b0; }
.cgmap a.cgmap-credit:focus-visible { outline: 2px solid var(--cgmap-accent, #1695e8); outline-offset: -2px; box-shadow: none; border-color: transparent; }

/* A word of help that comes and goes ("Click the map, then scroll to zoom") */
.cgmap-hint {
  position: absolute; left: 50%; top: 12px; max-width: calc(100% - 110px); padding: 5px 12px; border-radius: 999px; transform: translate(-50%, -6px);
  background: rgba(21, 24, 28, .86); color: #fff; font: 600 12px/1.4 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.cgmap-hint.cgmap-show { opacity: 1; transform: translate(-50%, 0); }

/* The pictures could not be fetched: a tidy panel in the map's place, never broken images */
.cgmap-fallback {
  position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 6px; padding: 20px 24px;
  background: var(--cgmap-surface-2, #f6f7f9); color: var(--cgmap-muted, #5f6873); text-align: center; cursor: default;
  font: 400 13.5px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}
.cgmap-fallback p { margin: 0; max-width: 44ch; }
.cgmap-fallback .cgmap-fallback-title { color: var(--cgmap-ink, #171b21); font-weight: 650; font-size: 15px; }
.cgmap-fallback > .cgmap-glyph { width: 34px; height: 34px; margin-bottom: 4px; stroke-width: 1.5; }
.cgmap .cgmap-retry {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; padding: 7px 14px; min-height: 36px;
  border: 1px solid var(--cgmap-line, #cbd0d7); border-radius: 9px; background: var(--cgmap-surface, #fff); color: var(--cgmap-ink, #171b21);
  font: 600 13.5px/1.2 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; cursor: pointer;
}
.cgmap .cgmap-retry:hover { border-color: var(--cgmap-accent, #1695e8); background: var(--cgmap-hover, #f1f3f5); }
.cgmap .cgmap-retry:focus-visible { outline: 2px solid var(--cgmap-accent, #1695e8); outline-offset: 2px; box-shadow: none; }
.cgmap .cgmap-retry .cgmap-glyph { width: 16px; height: 16px; }
.cgmap-down { cursor: default; }
.cgmap-down .cgmap-layer, .cgmap-down .cgmap-marks, .cgmap-down .cgmap-controls, .cgmap-down .cgmap-scale, .cgmap-down .cgmap-credit, .cgmap-down .cgmap-hint { display: none; }

@media (pointer: coarse) { .cgmap .cgmap-btn { width: 42px; height: 42px; } }
@media (prefers-reduced-motion: reduce) {
  .cgmap-layer img, .cgmap-ghost, .cgmap-hint, .cgmap-zooming .cgmap-pin, .cgmap-zooming .cgmap-accuracy { transition: none; }
}
@media (forced-colors: active) {
  .cgmap .cgmap-btn, .cgmap .cgmap-retry { border: 1px solid ButtonText; }
  .cgmap-pin-body { fill: Highlight; stroke: Canvas; }
  .cgmap-accuracy { border-color: Highlight; }
}
@media print { .cgmap-controls, .cgmap-hint { display: none; } }
