/* AI Plays Games Squaremap chrome. Uses shared /static/brand.css tokens/classes.
   Top-bar brand DOM: /static/header-lockup.js only (see operator/tests/test_brand_header_lockup.py). */

html,
body.aipg-squaremap-brand {
  height: 100%;
  margin: 0;
}

body.aipg-squaremap-brand,
body.aipg-squaremap-brand *,
body.aipg-squaremap-brand *::before,
body.aipg-squaremap-brand *::after {
  box-sizing: border-box;
}

body.aipg-squaremap-brand {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body.aipg-squaremap-brand #map {
  position: fixed;
  top: var(--brand-header-height);
  right: 0;
  bottom: var(--aipg-model-bar-height, 52px);
  left: 0;
  width: auto;
  height: auto;
}

:root {
  --aipg-model-bar-height: 52px;
}

.aipg-model-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1200;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--aipg-model-bar-height);
  padding: 0.4rem 0.75rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  background: var(--bg);
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -4px 24px var(--shadow);
}

.aipg-model-bar__label {
  margin: 0 0.35rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.aipg-model-bar button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--panel-stroke-strong);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.85rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--surface-soft);
  transition: filter 0.15s ease, transform 0.1s ease;
}

.aipg-model-bar__icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.15em;
  height: 1.15em;
  background-color: currentColor;
  -webkit-mask-image: var(--aipg-model-icon-url, none);
          mask-image: var(--aipg-model-icon-url, none);
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: contain;
          mask-size: contain;
}

.aipg-model-bar__icon[data-model-id="claude"] {
  --aipg-model-icon-url: url("/icons/claude.svg");
}

.aipg-model-bar__icon[data-model-id="chatgpt"] {
  --aipg-model-icon-url: url("/icons/chatgpt.svg");
}

/* Kimi mark is a multi-color rounded-square PNG; paint the asset directly
   instead of masking it to currentColor so the wordmark stays legible. */
.aipg-model-bar__icon[data-model-id="kimi"] {
  background-color: transparent;
  -webkit-mask-image: none;
          mask-image: none;
  background-image: url("/icons/kimi.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.aipg-model-bar button:hover {
  filter: brightness(1.08);
}

.aipg-model-bar button:active {
  transform: scale(0.98);
}

.aipg-model-bar button[data-model-id="claude"] {
  background: var(--model-claude);
}

.aipg-model-bar button[data-model-id="chatgpt"] {
  background: var(--model-chatgpt);
}

.aipg-model-bar button[data-model-id="kimi"] {
  background: var(--model-kimi);
}

.aipg-spawn-marker {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid var(--panel);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 0 2px var(--shadow-ink);
  line-height: 1;
}

.aipg-spawn-marker svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.aipg-spawn-marker-shell[data-spawn-id="claude"] {
  transform: translate(-10px, 0);
}

.aipg-spawn-marker-shell[data-spawn-id="chatgpt"] {
  transform: translate(10px, 0);
}

.aipg-spawn-marker[data-spawn-id="claude"] {
  background: var(--model-claude);
}

.aipg-spawn-marker[data-spawn-id="chatgpt"] {
  background: var(--model-chatgpt);
}

.aipg-spawn-marker[data-spawn-id="kimi"] {
  background: var(--model-kimi);
}

body.aipg-squaremap-brand div.leaflet-control-layers.coordinates,
body.aipg-squaremap-brand div.leaflet-control-layers.link {
  color: var(--text);
  background: var(--bg);
  border-color: var(--hairline);
}

body.aipg-squaremap-brand div.leaflet-control-layers.link img {
  filter: invert(1);
}

body.aipg-squaremap-brand .leaflet-control {
  color: var(--text);
}

body.aipg-squaremap-brand .leaflet-control-layers {
  background: var(--bg);
  border-color: var(--hairline);
}

body.aipg-squaremap-brand .leaflet-control-layers-expanded {
  background: var(--bg);
  color: var(--text);
}

body.aipg-squaremap-brand .leaflet-control-layers-toggle {
  filter: invert(1) brightness(1.2);
}

body.aipg-squaremap-brand .leaflet-control-layers-separator {
  border-top-color: var(--hairline);
}

body.aipg-squaremap-brand .leaflet-bar {
  border-color: var(--hairline);
}

body.aipg-squaremap-brand .leaflet-bar a,
body.aipg-squaremap-brand .leaflet-bar a:focus {
  background-color: var(--bg);
  color: var(--text);
  border-bottom-color: var(--hairline);
}

body.aipg-squaremap-brand .leaflet-bar a:hover {
  background-color: var(--surface-soft);
  color: var(--text);
}

body.aipg-squaremap-brand .leaflet-bar a.leaflet-disabled {
  background-color: var(--bg);
  color: var(--muted);
}

body.aipg-squaremap-brand .leaflet-control-layers-list,
body.aipg-squaremap-brand .leaflet-control-layers label,
body.aipg-squaremap-brand .leaflet-control-layers-base,
body.aipg-squaremap-brand .leaflet-control-layers-overlays {
  color: var(--text);
  background: transparent;
}

body.aipg-squaremap-brand .leaflet-control-attribution,
body.aipg-squaremap-brand .leaflet-control-attribution a {
  background: var(--bg);
  color: var(--muted);
}

body.aipg-squaremap-brand .leaflet-control-attribution a:hover {
  color: var(--text);
}

body.aipg-squaremap-brand .leaflet-popup-content-wrapper,
body.aipg-squaremap-brand .leaflet-popup-tip {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hairline);
}

/* Squaremap's collapsed #sidebar keeps padding-left + rgba(0,0,0,0.6) even at
   width:0, which paints a semi-opaque vertical strip on the right (especially
   visible on mobile). Hide that chrome until the operator opens the sidebar. */
body.aipg-squaremap-brand #sidebar:not(.show) {
  padding-left: 0;
  background-color: transparent;
  border-left-color: transparent;
}

body.aipg-squaremap-brand #sidebar:not(.show) fieldset {
  visibility: hidden;
}

body.aipg-squaremap-brand #sidebar:not(.show) #pin {
  pointer-events: auto;
  visibility: visible;
}

@media (max-width: 719px) {
  /* Pin targets desktop sidebar UX; on phones the model bar covers navigation. */
  body.aipg-squaremap-brand #sidebar {
    display: none !important;
  }
}
