/* =====================================================================
   Battle map: the Map tab on a campaign. A dark tabletop the map sits on,
   tokens like painted wooden discs, and fog that is solid for players and
   see-through for the DM.
   ===================================================================== */
.bm { display: flex; flex-direction: column; gap: .6rem; --z: 1; }
.bm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.bm-bar[hidden] { display: none; }
.bm-pick select { width: auto; max-width: 15rem; }
.bm-sep { width: 1px; align-self: stretch; background: var(--line2); margin: 0 .15rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-sm); background: var(--panel2); border: 1px solid var(--line2); }
.seg-b { font: inherit; font-weight: 700; font-size: .9rem; border: 0; background: none; color: var(--muted); padding: .35rem .7rem; border-radius: calc(var(--r-sm) - 2px); cursor: pointer; }
.seg-b.on { background: var(--accent); color: var(--accent-ink); }
.bm-more { position: relative; }
.bm-more > summary { list-style: none; cursor: pointer; }
.bm-more > summary::-webkit-details-marker { display: none; }
.bm-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 14rem; display: flex; flex-direction: column; padding: .3rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 10px 30px #0004); }
.bm-menu button { font: inherit; text-align: left; padding: .5rem .7rem; border: 0; background: none; color: var(--ink); border-radius: var(--r-sm); cursor: pointer; }
.bm-menu button:hover { background: var(--panel2); }
.bm-menu .danger { color: var(--bad, #a33); }

.bm-view { position: relative; height: clamp(420px, 72vh, 940px); overflow: hidden; border-radius: var(--r-lg, 12px); cursor: grab; touch-action: none; outline: none;
  background: radial-gradient(120% 90% at 50% 40%, #2a2119, #120d09); border: 1px solid var(--line); box-shadow: inset 0 2px 30px #0008; user-select: none; -webkit-user-select: none; }
.bm-view:focus-visible { box-shadow: inset 0 2px 30px #0008, 0 0 0 3px var(--gilt, var(--accent)); }
.bm-view:active { cursor: grabbing; }
.bm-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 20px 60px -10px #000c; }
.bm-img { display: block; width: 100%; height: 100%; pointer-events: none; }
.bm-noimg { width: 100%; height: 100%; display: grid; place-items: center; color: #cbbd9f; background: #2a2119; font-size: 2rem; }
.bm-grid, .bm-fog, .bm-sel { position: absolute; inset: 0; pointer-events: none; }
.bm-gl { stroke: #000; stroke-opacity: .42; stroke-width: 1; vector-effect: non-scaling-stroke; }
.bm-fogp { fill: #0d0a08; }
.is-dm .bm-fogp { fill: #0d0a08; fill-opacity: .58; }
.bm-sel rect { vector-effect: non-scaling-stroke; stroke-width: 2; stroke-dasharray: 6 4; }
.bm-sel rect.rev { fill: #e3c27e40; stroke: #e3c27e; }
.bm-sel rect.hid { fill: #00000059; stroke: #f3ead8; }

/* tokens: painted discs with a colored rim, name tag under */
.bm-tokens { position: absolute; inset: 0; }
.bm-tok { position: absolute; }
.bm-tok.can { cursor: grab; }
.bm-tok.drag { z-index: 5; cursor: grabbing; filter: drop-shadow(0 10px 10px #000a); }
.bm-tok.drag .bm-disc { transform: scale(1.08); }
.bm-disc { position: absolute; inset: 6%; border-radius: 50%; overflow: hidden; display: grid; place-items: center; transition: transform .12s;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--tc) 70%, #fff), var(--tc) 55%, color-mix(in srgb, var(--tc) 60%, #000));
  box-shadow: 0 0 0 max(2px, 6%) var(--tc), 0 0 0 calc(max(2px, 6%) + 1.5px) #0009, 0 4px 8px #0008; }
.bm-disc img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.bm-disc span { color: #fff; font-weight: 800; line-height: 1; text-shadow: 0 1px 2px #000a; }
.bm-tok.mine .bm-disc { box-shadow: 0 0 0 max(2px, 6%) var(--tc), 0 0 0 calc(max(2px, 6%) + 3px) #f2cf6b, 0 4px 10px #000a; }
.bm-tok.hid { opacity: .5; }
.bm-tok.hid .bm-disc { outline: 2px dashed #f3ead8; outline-offset: 2px; }
.bm-name { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 2px) scale(calc(1 / var(--z))); transform-origin: 50% 0; white-space: nowrap;
  font: 700 12px/1.2 var(--body); color: #f6ecd6; background: #140e09d9; padding: 1px 6px; border-radius: 99px; pointer-events: none; max-width: 14em; overflow: hidden; text-overflow: ellipsis; }

.bm-zoom { position: absolute; right: .6rem; bottom: .6rem; display: flex; gap: .3rem; }
.bm-zoom .btn { min-width: 2.4rem; justify-content: center; background: #140e09d9; color: #f3ead8; border-color: #ffffff2e; backdrop-filter: blur(4px); }
.bm-measure { position: absolute; left: 50%; top: .7rem; transform: translateX(-50%); padding: .3rem .9rem; border-radius: 99px; font-weight: 800; font-size: 1.1rem;
  color: #2a1c05; background: #f2cf6b; box-shadow: 0 6px 18px #0007; pointer-events: none; font-variant-numeric: tabular-nums; }
.bm-private { position: absolute; left: .6rem; top: .6rem; max-width: calc(100% - 1.2rem); padding: .35rem .75rem; border-radius: var(--r-sm); font-size: .9rem;
  color: #f3ead8; background: #140e09d9; border: 1px dashed #e3c27e99; pointer-events: none; }
.bm-empty { text-align: center; padding: 2.5rem 1.2rem; }
.bm-empty p { max-width: 52ch; margin-inline: auto; }

/* full screen: the map takes the whole window, controls stay on top */
.bm.full { position: fixed; inset: 0; z-index: 260; padding: .6rem; padding-top: max(.6rem, env(safe-area-inset-top)); padding-bottom: max(.6rem, env(safe-area-inset-bottom)); background: var(--bg); }
.bm.full .bm-view { flex: 1; height: auto; }

/* dialogs */
.modal-bg.see-through { background: #0000001f; backdrop-filter: none; }
.bm-up { position: relative; cursor: pointer; }
.bm-up.busy { opacity: .7; pointer-events: none; }
.bm-colors { display: flex; flex-wrap: wrap; gap: .4rem; border: 0; padding: 0; margin: 0; }
.bm-colors legend { font-weight: 700; margin-bottom: .3rem; }
.bm-colors label { cursor: pointer; }
.bm-colors input { position: absolute; opacity: 0; }
.bm-colors span { display: block; width: 2rem; height: 2rem; border-radius: 50%; box-shadow: inset 0 0 0 2px #0003; }
.bm-colors input:checked + span { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--ink); }
.bm-colors input:focus-visible + span { outline: 2px solid var(--gilt, var(--accent)); outline-offset: 3px; }
.grid2.tight { gap: .6rem; }

@media (max-width: 700px) {
  .bm-view { height: 62vh; }
  .bm-bar .btn { padding-inline: .6rem; }
}
@media print { .bm-zoom, .bm-bar { display: none !important; } }
