/* Map changes (js/map-view.js): the map with its markers, filters, the grouped list and the details card; the patch
   overview's small map; and the build overview's list of file sources. Markers never rely on colour alone: added is a
   circle, removed a crossed circle, changed a diamond, moved an arrow from a ring (old place) to the new place. */
/* The map screen's heading: back to the patch, the title, which builds it compares. */
.map-heading { align-items: center; gap: .5rem 1rem; padding: .375rem .5rem .25rem; }
.map-heading .map-back { order: 3; margin-left: auto; }
.map-open { align-self: flex-start; }
.map-screen { display: flex; flex-direction: column; gap: .75rem; }
.map-head { gap: .5rem .75rem; }
.map-head .block-meta { overflow-wrap: anywhere; }
/* The picker is filled in once the other maps are checked; its host does not change the header's layout. */
.map-picker-host { display: contents; }
.map-select { height: 1.875rem; font-size: .7812rem; max-width: 14rem; }
.map-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.5rem; margin: -.25rem 0 1rem; font-size: .8125rem; }
.map-stat { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .5rem; }
.map-stat-label { color: var(--text-3); font-size: .6875rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.map-counts { display: inline-flex; flex-wrap: wrap; gap: .125rem .75rem; font: .8125rem var(--font-mono); font-variant-numeric: tabular-nums; }
.map-counts.compact { gap: .125rem .5rem; font-size: .75rem; }
.mc-moved, .mc-changed { color: var(--modified-text); }
.mc-added { color: var(--added-text); }
.mc-removed { color: var(--removed-text); }

/* Desktop: the list beside the map is as tall as the map column and scrolls on its own (contain: size keeps its
   content from making the row taller), so map and list stay in view together. */
.map-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(17.5rem, 1fr); gap: 1.25rem; align-items: stretch; }
.map-main { display: flex; flex-direction: column; gap: .625rem; min-width: 0; }
.map-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; min-height: 0; }
.map-side > .map-list { flex: 1 1 0; min-height: 16rem; overflow-y: auto; contain: size; margin-right: -.5rem; padding-right: .5rem; }
.map-foot { margin-top: 1rem; font-size: .7188rem; line-height: 1.5; }

/* ------------------------------------------------------------ canvas */
.map-canvas {
  --map-halo: rgba(8, 9, 12, .82);
  position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: .75rem;
  border: 1px solid var(--line); background: #0d0f13; user-select: none; -webkit-user-select: none;
}
.map-canvas.interactive { cursor: grab; touch-action: none; }
.map-canvas.panning { cursor: grabbing; }
.map-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.map-canvas.compact { border-radius: .625rem; }
.map-svg { display: block; width: 100%; height: 100%; }
.map-grid-bg { fill: var(--surface-2); }
.map-canvas[data-base="grid"] { background: var(--surface-2); }
.map-grid { fill: none; stroke: var(--line); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.map-axes { fill: none; stroke: var(--line-2); stroke-width: 1px; vector-effect: non-scaling-stroke; }

.mk { cursor: pointer; }
.map-canvas:not(.interactive) .mk { cursor: inherit; }
.mk > circle, .mk > path:first-child, .mk > rect { stroke: var(--map-halo); stroke-width: 1.5px; }
.mk-added > circle { fill: var(--added); }
.mk-removed > circle { fill: var(--removed); }
.mk-removed > .mk-cross { fill: none; stroke: #fff; stroke-width: 1.7px; stroke-linecap: round; }
.mk-changed > path { fill: var(--modified); }
.mk-moved > path { fill: var(--modified); }
.mk-origin > circle { fill: rgba(8, 9, 12, .45); stroke: var(--modified); stroke-width: 1.6px; }
.mk-link { stroke: var(--modified); stroke-width: 1.75px; vector-effect: non-scaling-stroke; opacity: .9; }
.ctx > rect { fill: rgba(233, 235, 239, .62); stroke: rgba(8, 9, 12, .7); stroke-width: 1px; }
.ctx:hover > rect { fill: #fff; }
.mk:not(.ctx):hover > :first-child { stroke: #fff; }
.mk.selected > :first-child { stroke: var(--accent); stroke-width: 2px; }
.tree { stroke: rgba(8, 9, 12, .55); stroke-width: .75px; vector-effect: non-scaling-stroke; }
.tree-added { fill: var(--added); }
.tree-removed { fill: var(--removed); }
.tree-changed, .tree-moved { fill: var(--modified); }
.tree-link { stroke: var(--modified); stroke-width: 1px; vector-effect: non-scaling-stroke; opacity: .8; }

.map-tools {
  position: absolute; top: .5rem; right: .5rem; display: flex; flex-direction: column; gap: 2px; padding: 2px;
  border-radius: .5rem; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(8px); box-shadow: var(--shadow-pop);
}
.map-tip {
  position: absolute; z-index: 3; display: flex; flex-direction: column; gap: .1875rem; max-width: min(20rem, 80%);
  padding: .5rem .625rem; border-radius: .5rem; border: 1px solid var(--line-2); background: var(--surface-1); box-shadow: var(--shadow-pop);
  font-size: .75rem; line-height: 1.4; pointer-events: none;
}
.map-tip[hidden] { display: none; }
.map-tip-head { display: flex; align-items: center; flex-wrap: wrap; gap: .375rem; }
.map-tip-name { font-size: .7188rem; overflow-wrap: anywhere; }
.map-tip-body { color: var(--text-2); overflow-wrap: anywhere; }

/* Change kinds as small shapes (list, legend, details): the same shapes as on the map. */
.map-kind-dot { display: inline-block; width: .625rem; height: .625rem; flex: none; }
.map-kind-dot.k-added { border-radius: 50%; background: var(--added); }
.map-kind-dot.k-removed {
  border-radius: 50%; background-color: var(--removed);
  background-image: linear-gradient(45deg, transparent 41%, #fff 41% 59%, transparent 59%), linear-gradient(-45deg, transparent 41%, #fff 41% 59%, transparent 59%);
}
.map-kind-dot.k-changed { background: var(--modified); border-radius: 1px; transform: rotate(45deg) scale(.8); }
.map-kind-dot.k-moved { background: var(--modified); clip-path: polygon(0 12%, 100% 50%, 0 88%, 22% 50%); }
.map-kind-dot.k-context { background: var(--text-3); border-radius: 2px; transform: scale(.75); }
.map-legend { gap: .375rem 1rem; }

/* ------------------------------------------------------------ filters */
.map-filters { display: flex; flex-direction: column; gap: .625rem; }
.map-filter-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.map-kinds { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.map-kinds::-webkit-scrollbar { display: none; }
.map-kinds .mk-seg::before { content: ""; width: .5rem; height: .5rem; flex: none; }
.map-kinds .k-added::before { border-radius: 50%; background: var(--added); }
.map-kinds .k-removed::before { border-radius: 50%; background: var(--removed); }
.map-kinds .k-changed::before { background: var(--modified); transform: rotate(45deg) scale(.8); }
.map-kinds .k-moved::before { background: var(--modified); clip-path: polygon(0 12%, 100% 50%, 0 88%, 22% 50%); }
.map-chips { display: flex; flex-wrap: wrap; gap: .375rem; }
.map-chip {
  display: inline-flex; align-items: center; gap: .375rem; height: 1.75rem; padding: 0 .625rem; border-radius: 62.4375rem;
  border: 1px solid var(--line-2); background: var(--surface-1); color: var(--text-2); font-size: .75rem; font-weight: 550; white-space: nowrap;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.map-chip:hover { color: var(--text); border-color: var(--text-3); }
.map-chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent-line); background: var(--accent-soft); }
.map-chip[aria-pressed="false"] .map-cat-swatch { opacity: .35; }
.map-chip-count { color: var(--text-3); font: .6875rem var(--font-mono); font-variant-numeric: tabular-nums; }
.map-toggle { display: inline-flex; align-items: center; gap: .5rem; color: var(--text-2); font-size: .7812rem; cursor: pointer; }
.map-toggle input { accent-color: var(--accent); width: .9375rem; height: .9375rem; }

/* Category swatches use the file-category hues (never the change colours). */
.map-cat-swatch { display: inline-block; width: .5625rem; height: .5625rem; border-radius: 2px; flex: none; background: var(--cat-other); }
.cat-towers .map-cat-swatch, .map-cat-swatch.cat-towers { background: var(--cat-model); }
.cat-buildings .map-cat-swatch, .map-cat-swatch.cat-buildings { background: var(--cat-folder); }
.cat-camps .map-cat-swatch, .map-cat-swatch.cat-camps { background: var(--cat-particle); }
.cat-runes .map-cat-swatch, .map-cat-swatch.cat-runes { background: var(--cat-panorama); }
.cat-objectives .map-cat-swatch, .map-cat-swatch.cat-objectives { background: var(--cat-material); }
.cat-watchers .map-cat-swatch, .map-cat-swatch.cat-watchers { background: var(--cat-sound); }
.cat-shops .map-cat-swatch, .map-cat-swatch.cat-shops { background: var(--cat-script); }
.cat-vision .map-cat-swatch, .map-cat-swatch.cat-vision { background: var(--cat-video); }
.cat-spawners .map-cat-swatch, .map-cat-swatch.cat-spawners { background: var(--cat-animation); }
.cat-paths .map-cat-swatch, .map-cat-swatch.cat-paths { background: var(--text-2); }
.cat-trees .map-cat-swatch, .map-cat-swatch.cat-trees { background: var(--cat-texture); border-radius: 50%; }

/* ------------------------------------------------------------ list and details */
.map-list { display: flex; flex-direction: column; gap: 1rem; }
.map-group-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .5rem; margin-bottom: .25rem;
  color: var(--text-2); font-size: .6875rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
}
.map-group-head .map-counts { letter-spacing: 0; text-transform: none; }
.map-group-count { color: var(--text-3); font: .6875rem var(--font-mono); letter-spacing: 0; }
.map-items { display: flex; flex-direction: column; margin: 0 -.375rem; padding: 0; list-style: none; }
.map-item {
  display: grid; grid-template-columns: .75rem minmax(0, 1fr); gap: .5rem; align-items: start; width: 100%;
  padding: .4375rem .5rem; border-radius: .5rem; text-align: left; transition: background var(--t-fast) var(--ease);
}
.map-item > .map-kind-dot { margin-top: .3125rem; }
.map-item:hover { background: var(--surface-2); }
.map-item.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.map-item-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.map-item-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: .125rem .5rem; font-size: .8125rem; }
.map-item-title b { font-weight: 600; }
.map-item-name { color: var(--text-2); font-size: .7188rem; overflow-wrap: anywhere; }
.map-item-sub { color: var(--text-2); font-size: .75rem; line-height: 1.4; overflow-wrap: anywhere; }
.map-team { padding: 0 .375rem; border-radius: 62.4375rem; border: 1px solid var(--line-2); color: var(--text-2); font-size: .6562rem; font-weight: 600; white-space: nowrap; }
.map-trees-note { font-size: .75rem; line-height: 1.5; }

.map-details-hint { font-size: .75rem; }
.map-card { padding: .75rem .875rem; border-radius: .75rem; border: 1px solid var(--line); background: var(--surface-2); }
.map-card-head { display: flex; align-items: flex-start; gap: .625rem; }
.map-card-head > .map-kind-dot { margin-top: .375rem; }
.map-card-titles { flex: 1; min-width: 0; }
.map-card-titles h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: .125rem .5rem; font-size: .875rem; font-weight: 650; }
.map-card-kind { color: var(--text-3); font-size: .6562rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; }
.map-card-titles p { margin-top: .125rem; font-size: .7188rem; overflow-wrap: anywhere; }
.map-card-desc { margin-top: .5rem; font-size: .75rem; line-height: 1.45; }
.map-dl { display: grid; grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr); gap: .3125rem .75rem; margin: .625rem 0 0; font-size: .75rem; line-height: 1.4; }
.map-dl-row { display: contents; }
.map-dl dt { color: var(--text-2); overflow-wrap: anywhere; }
.map-dl dd { margin: 0; overflow-wrap: anywhere; }
.map-key { margin-left: .375rem; color: var(--text-3); font-size: .6562rem; }
.map-old { color: var(--removed-text); }
.map-new { color: var(--added-text); }

/* ------------------------------------------------------------ patch overview section */
.map-summary { display: grid; grid-template-columns: minmax(10rem, 17.5rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.map-thumb { display: block; border-radius: .625rem; }
.map-thumb:hover .map-canvas { border-color: var(--text-3); }
.map-summary-side { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.map-summary-side > .btn { align-self: flex-start; }
.map-summary-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .625rem; }
.map-cat-rows { display: flex; flex-direction: column; margin: 0 -.375rem; }
.map-cat-row {
  display: grid; grid-template-columns: .5625rem minmax(0, 1fr) auto; align-items: center; gap: .5rem;
  padding: .3125rem .375rem; border-radius: .375rem; font-size: .8125rem;
}
.map-cat-row:hover { background: var(--surface-2); }
.map-cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-hls { display: flex; flex-direction: column; gap: .25rem; margin: 0; padding: 0; list-style: none; font-size: .75rem; }
.map-hl { display: grid; grid-template-columns: .625rem minmax(0, 1fr); gap: .5rem; align-items: center; }
.map-hl-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-hl-text b { font-weight: 600; }
.map-others { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .5rem; margin-top: .875rem; font-size: .75rem; }
/* Each map's name and its heart share one frame: a loose heart between two names read as belonging to either. */
.map-others .tag-like { gap: 0; border: 1px solid var(--line-2); }
.map-others .tag-like > .tag { border: 0; }
.map-others .tag-like > .like-btn.compact { height: 1.25rem; min-width: 1.5rem; padding: 0 .25rem; border: 0; border-left: 1px solid var(--line-2); }
.map-others .tag-like > .like-btn.compact.liked { border-left-color: var(--like-line); }
.map-note { font-size: .8125rem; }

/* ------------------------------------------------------------ build sources (build overview) */
.sources-intro { max-width: 52rem; margin: -.25rem 0 .875rem; font-size: .8125rem; line-height: 1.5; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: .625rem; }
.source-card {
  display: grid; grid-template-columns: 1.375rem minmax(0, 1fr); gap: .625rem; padding: .625rem .75rem; border-radius: .625rem;
  border: 1px solid var(--line); background: var(--surface-2); transition: border-color var(--t-fast) var(--ease);
}
.source-card:hover { border-color: var(--accent-line); }
.source-icon .file-icon svg { width: 1.125rem; height: 1.125rem; }
.source-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.source-name { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; font-size: .8125rem; font-weight: 600; }
.source-meta { color: var(--text-2); font-size: .75rem; }
.source-depot { font-size: .6875rem; overflow-wrap: anywhere; }

/* Preview pane: a note above the body (an entity lump links to the map screen). */
.pv-notices:empty { display: none; }
.pv-map-notice .link-arrow { margin-left: auto; font-size: .75rem; }

@media (max-width: 900px) {
  .map-layout { grid-template-columns: minmax(0, 1fr); }
  .map-side > .map-list { flex: none; min-height: 0; overflow: visible; contain: none; margin-right: 0; padding-right: 0; }
}
@media (max-width: 640px) {
  /* The map list across the line under the title (it started a third of the way in). */
  .map-head > .grow { display: none; }
  .map-picker-host { display: flex; flex: 1 1 100%; min-width: 0; }
  .map-select { flex: 1; width: 100%; min-width: 0; max-width: none; }
  .map-summary { grid-template-columns: minmax(0, 1fr); }
  .map-thumb { width: min(100%, 20rem); }
  .map-dl { grid-template-columns: minmax(0, 1fr); gap: .125rem; }
  .map-dl dd { margin-bottom: .375rem; }
  .map-stats { gap: .375rem 1rem; }
  .map-heading .map-back { order: 0; margin-left: 0; }
  .pv-map-notice { flex-wrap: wrap; }
}
