/* Groups in the prototype (groups.js). Uses the page's theme tokens (--panel, --text, ...), so dark and
   light follow index.html's data-theme. Everything is prefixed gp- to stay out of the page's way. */

.gp-hidden { display: none !important; }
.gp-btn { border: 0; border-radius: 8px; padding: 7px 12px; background: var(--chip); color: var(--text); cursor: pointer;
  font: 500 13px/1.2 system-ui, sans-serif; white-space: nowrap; }
.gp-btn:hover { filter: brightness(1.12); }
.gp-btn.primary { background: var(--chip-on); color: var(--chip-on-text); font-weight: 600; }
.gp-btn.danger { color: #ff6b6b; }
:root[data-theme="light"] .gp-btn.danger { color: #c92a2a; }
.gp-btn.small { padding: 4px 9px; font-size: 12px; }
.gp-btn:disabled { opacity: 0.5; cursor: default; }
.gp-link { all: unset; cursor: pointer; color: var(--accent); font-weight: 600; }
.gp-link:hover { text-decoration: underline; }
.gp-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85); }
:root[data-theme="light"] .gp-dot { box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.35); }
.gp-muted { color: var(--muted); }
.gp-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.03em; }

/* Group button in the right-hand tool column */
.gp-badge { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #2fbf71; color: #fff; font: 700 10px/16px system-ui, sans-serif; text-align: center; pointer-events: none; }
.gp-badge:empty { display: none; }
.gp-badge.off { background: #8a8f98; }

/* slide-over panel */
#gp-panel { position: absolute; top: 12px; right: 72px; z-index: 6; width: min(340px, calc(100vw - 96px));
  max-height: calc(100% - 60px); display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(16px); opacity: 0; pointer-events: none; transition: transform 180ms ease, opacity 180ms ease; }
#gp-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.gp-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 14px; border-bottom: 1px solid var(--line); }
.gp-head h2 { margin: 0; font: 600 16px/1.2 system-ui, sans-serif; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-close { all: unset; cursor: pointer; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.gp-close:hover { background: var(--chip); color: var(--text); }
.gp-body { overflow: auto; padding: 4px 14px 14px; }
.gp-section { padding: 10px 0; border-bottom: 1px solid var(--line); }
.gp-section:last-child { border-bottom: 0; }
.gp-section h3 { margin: 0 0 8px; font: 600 12px/1.2 system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.gp-form { display: flex; flex-direction: column; gap: 8px; }
.gp-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.gp-input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel-solid);
  color: var(--text); font: 14px/1.3 system-ui, sans-serif; outline: none; }
.gp-input:focus { border-color: var(--accent); }
textarea.gp-input { resize: vertical; min-height: 64px; }
.gp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gp-error { color: #ff6b6b; font-size: 12px; min-height: 0; }
:root[data-theme="light"] .gp-error { color: #c92a2a; }
.gp-error:empty { display: none; }
.gp-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.gp-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.gp-status i { width: 8px; height: 8px; border-radius: 50%; background: #2fbf71; }
.gp-status.off i { background: #e0a020; }

.gp-me { display: flex; align-items: center; gap: 8px; }
.gp-name { all: unset; cursor: text; font-weight: 600; border-bottom: 1px dashed var(--muted); overflow-wrap: anywhere; }
.gp-name:hover { border-bottom-color: var(--accent); }
.gp-name-input { flex: 1; min-width: 0; }

.gp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.gp-item { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 8px; min-height: 34px; }
.gp-item:hover { background: var(--chip); }
.gp-item .gp-grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-item.offline .gp-grow { opacity: 0.55; }
.gp-item.clickable { cursor: pointer; }
.gp-item small { color: var(--muted); white-space: nowrap; }
.gp-kind { width: 22px; height: 22px; flex: none; }
.gp-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
details.gp-section summary { cursor: pointer; list-style: none; }
details.gp-section summary::-webkit-details-marker { display: none; }
details.gp-section summary h3 { display: inline; }
details.gp-section summary::after { content: "▸"; float: right; color: var(--muted); }
details.gp-section[open] summary::after { content: "▾"; }
details.gp-section[open] summary { margin-bottom: 8px; }

/* toolbar: left column, flyouts open to the right */
#gp-bar { position: absolute; left: 12px; top: 72px; z-index: 2; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.gp-tools { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.gp-tool { position: relative; width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); cursor: pointer;
  display: grid; place-items: center; padding: 0; }
.gp-tools .gp-tool:first-child { border-radius: 13px 13px 0 0; }
.gp-tools .gp-tool:last-child { border-radius: 0 0 13px 13px; }
.gp-tools .gp-tool + .gp-tool { border-top: 1px solid var(--line); }
.gp-tool:hover { background: var(--chip); }
.gp-tool.on { background: var(--chip-on); color: var(--chip-on-text); }
.gp-tool svg { width: 24px; height: 24px; }
.gp-tool .gp-cswatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--panel-solid); box-shadow: 0 0 0 1px var(--line); }
.gp-tool[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px;
  font: 500 13px/1 system-ui, sans-serif; box-shadow: var(--shadow); pointer-events: none; z-index: 1; }
.gp-wrap { position: relative; display: flex; align-items: flex-start; gap: 8px; }
.gp-fly { position: absolute; left: 52px; top: 0; z-index: 3; padding: 6px; display: grid; grid-template-columns: repeat(6, 56px); gap: 4px; }
.gp-fly.colours { grid-template-columns: repeat(8, 30px); }
.gp-fly button { border: 0; background: transparent; color: var(--text); cursor: pointer; border-radius: 10px; padding: 6px 2px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font: 500 11px/1 system-ui, sans-serif; }
.gp-fly button:hover, .gp-fly button.on { background: var(--chip); }
.gp-fly button svg { width: 26px; height: 26px; }
.gp-fly .gp-colour { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--panel-solid); box-shadow: 0 0 0 1px var(--line); }
.gp-fly .gp-colour.on { box-shadow: 0 0 0 2px var(--accent); }
@media (hover: none) { .gp-tool[data-tip]:hover::after { display: none; } }

/* the mode pill (placing, moving, drawing) sits next to the toolbar */
#gp-mode { position: absolute; left: 64px; top: 72px; z-index: 4; padding: 8px 10px; display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; max-width: calc(100vw - 88px); font-size: 13px; }
#gp-mode b { font-weight: 600; }
#gp-follow { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 4; padding: 6px 8px 6px 12px;
  display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }

/* toasts and the first-join hint */
#gp-toasts { position: absolute; right: 72px; top: 12px; z-index: 7; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none; max-width: min(360px, calc(100vw - 96px)); transition: right 180ms ease; }
#gp-toasts.shift { right: calc(84px + min(340px, 100vw - 96px)); }
.gp-toast { pointer-events: auto; padding: 9px 12px; font-size: 13px; display: flex; align-items: center; gap: 8px;
  animation: gp-in 160ms ease-out; transition: opacity 400ms ease, transform 400ms ease; }
.gp-toast.out { opacity: 0; transform: translateY(-6px); }
.gp-toast.hint { cursor: pointer; border-color: var(--accent); }
.gp-toast.error { border-color: #ff6b6b; }
@keyframes gp-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* on the map: other members' cursors and Pings (MapLibre Markers) */
.gp-cursor { pointer-events: none; display: flex; align-items: flex-start; }
.gp-cursor svg { width: 18px; height: 18px; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.6)); }
.gp-cursor span { margin: 14px 0 0 -2px; padding: 2px 7px; border-radius: 9px; color: #111; font: 600 11px/1.3 system-ui, sans-serif;
  white-space: nowrap; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.gp-ping { pointer-events: none; width: 0; height: 0; position: relative; }
.gp-ping i { position: absolute; left: -36px; top: -36px; width: 72px; height: 72px; border-radius: 50%; border: 3px solid var(--c);
  opacity: 0; animation: gp-ring 1.3s ease-out 3; }
.gp-ping i:nth-child(2) { animation-delay: 0.35s; }
.gp-ping b { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--c);
  border: 2px solid #fff; box-shadow: 0 0 6px rgba(0, 0, 0, 0.6); animation: gp-fade 4s ease-in forwards; }
.gp-ping span { position: absolute; left: 12px; top: -26px; padding: 2px 7px; border-radius: 9px; background: var(--c); color: #111;
  font: 600 11px/1.3 system-ui, sans-serif; white-space: nowrap; animation: gp-fade 4s ease-in forwards; }
@keyframes gp-ring { 0% { transform: scale(0.15); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
@keyframes gp-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

/* popups on Markers, Position Markers and Drawings */
.gp-popup .maplibregl-popup-content { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px 14px; font: 13px/1.4 system-ui, sans-serif; min-width: 210px; }
.gp-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--panel-solid); }
.gp-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--panel-solid); }
.gp-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--panel-solid); }
.gp-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--panel-solid); }
.gp-popup .maplibregl-popup-close-button { color: var(--muted); font-size: 18px; right: 4px; top: 2px; }
.gp-pop-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; padding-right: 16px; }
.gp-pop-note { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 160px; overflow: auto; }
.gp-pop-meta { margin-top: 6px; color: var(--muted); font-size: 12px; }
.gp-pop-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.gp-kinds { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; margin: 8px 0; }
.gp-kinds button { border: 0; background: transparent; border-radius: 8px; padding: 4px 0; cursor: pointer; display: grid; place-items: center; }
.gp-kinds button.on, .gp-kinds button:hover { background: var(--chip); }
.gp-kinds svg { width: 24px; height: 24px; }

/* phone: the panel is a bottom sheet, the toolbar sits under the Presets row */
@media (max-width: 640px) {
  #gp-panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 75vh; border-radius: 16px 16px 0 0;
    transform: translateY(24px); }
  #gp-panel.open { transform: none; }
  .gp-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  #gp-bar { top: 122px; }
  #gp-mode { top: 122px; left: 64px; right: 12px; max-width: none; }
  .gp-fly { grid-template-columns: repeat(3, 56px); }
  .gp-fly.colours { grid-template-columns: repeat(4, 30px); }
  #gp-toasts, #gp-toasts.shift { right: 12px; left: 12px; top: auto; bottom: 150px; align-items: center; max-width: none; }
  #gp-follow { top: 116px; left: auto; right: 72px; transform: none; }
}
