/* ── MAP VIEW ──
   A floor plan of boxes (rings, holding, staging) positioned by fractions of
   the canvas. Type sizes use container query units (cqw) so the text scales
   with the map; narrow screens get the same plan, edge to edge (.map-small). */

.map-btn {
  display:inline-flex; align-items:center; gap:6px; white-space:nowrap; cursor:pointer;
  font-family:'DM Sans',sans-serif; font-size:12px; padding:5px 11px; border-radius:6px;
  background:var(--ncta-input-bg); color:var(--ncta-text); border:1px solid var(--ncta-border);
  transition:border-color .15s;
}
.map-btn:hover:not([disabled]) { border-color:#555; }
.map-btn:focus-visible { outline:2px solid var(--red); outline-offset:2px; }
.map-btn[disabled] { opacity:.45; cursor:default; }
.map-btn[hidden] { display:none; }
.map-btn-primary { background:var(--red); border-color:var(--red); color:#fff; font-weight:600; }
.map-btn-danger { color:var(--red); }

/* Editing controls */
.map-edit-bar {
  display:flex; flex-direction:column; gap:8px; padding:10px 16px;
  background:var(--panel); border-bottom:1px solid var(--border);
  font-family:'DM Sans',sans-serif; font-size:12px; color:var(--text);
}
.map-edit-bar[hidden] { display:none; }
.map-edit-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.map-edit-row[hidden] { display:none; }
.map-snap { display:inline-flex; align-items:center; gap:6px; margin-left:auto; color:var(--muted); cursor:pointer; }
.map-inspector label { display:inline-flex; align-items:center; gap:6px; color:var(--muted); }
.map-inspector[hidden] , #mapInspRingWrap[hidden] { display:none; }
.map-inspector input {
  font:inherit; padding:4px 8px; border-radius:6px; width:150px;
  background:var(--ncta-input-bg); color:var(--ncta-text); border:1px solid var(--ncta-border);
}
.map-inspector input[type=number] { width:70px; }
.map-edit-error { color:var(--red); font-size:11px; }
.map-edit-actions { justify-content:flex-end; }
.map-edit-hint { margin-right:auto; color:var(--muted); font-size:11px; }

/* Stage + canvas */
.map-stage { padding:12px 16px 20px; }
.map-canvas {
  position:relative; width:100%; max-width:1500px; margin:0 auto; aspect-ratio:16 / 10;
  container-type:inline-size; overflow:hidden;
  background-color:var(--card-bg); border:1px solid var(--border); border-radius:10px;
  background-image:
    linear-gradient(var(--row-divider,rgba(128,128,128,.12)) 1px, transparent 1px),
    linear-gradient(90deg, var(--row-divider,rgba(128,128,128,.12)) 1px, transparent 1px);
  background-size:5% 8%;
}
.map-note { max-width:1500px; margin:10px auto 0; font-family:'DM Sans',sans-serif; font-size:12px; color:var(--muted); }
.map-note[hidden] { display:none; }

.map-el {
  position:absolute; box-sizing:border-box; display:flex; flex-direction:column; overflow:hidden;
  background:var(--panel); border:2px solid var(--border); border-radius:.7cqw;
  font-family:'DM Sans',sans-serif; font-size:clamp(9px, 1.05cqw, 16px); color:var(--text);
}
/* Every box keeps the same plain border — the match status shows on the cards
   inside (colored status text), not on the box outline. */
.map-el-head {
  display:flex; align-items:center; justify-content:space-between; gap:.5em; flex:none;
  padding:.45em .7em; background:var(--div-btn-bg); border-bottom:1px solid var(--border);
  font-weight:700; letter-spacing:.08em; text-transform:uppercase;
}
.map-el-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.map-el-count:not(:empty) {
  min-width:1.5em; padding:.1em .45em; border-radius:1em; text-align:center;
  background:var(--red); color:#fff; font-size:.9em;
}
/* Cards flow into columns once the box is wide enough for two or more of them
   (each column at least 17em: wide enough that a card's number, division,
   ring and status stay on one line), so a wide box
   shows its matches side by side instead of one long column. */
.map-el-body {
  position:relative; /* so cards' offsetTop is measured from this scroller */
  flex:1; min-height:0; overflow-y:auto; padding:.45em; gap:.45em; align-content:start;
  display:grid; grid-template-columns:repeat(auto-fill, minmax(min(17em, 100%), 1fr)); overflow-x:hidden;
}
.map-el-empty { grid-column:1 / -1; margin:auto; color:var(--muted); font-size:.95em; letter-spacing:.05em; text-transform:uppercase; opacity:.7; }

.map-match {
  display:flex; flex-direction:column; gap:.2em; width:100%; box-sizing:border-box; text-align:left; min-width:0;
  padding:.45em .55em; font:inherit; color:inherit; cursor:pointer;
  background:var(--card-bg); border:1px solid var(--border); border-radius:.5em;
}
.map-match:hover { border-color:var(--red); }
.map-match:focus-visible { outline:2px solid var(--red); outline-offset:1px; }
.map-match-top { display:flex; align-items:baseline; flex-wrap:wrap; gap:.2em .6em; font-size:.95em; }
.map-match-num { font-weight:700; }
.map-match-div { color:var(--muted); }
.map-match-ring { color:var(--yellow,#eab308); font-weight:700; }
.map-match-status { margin-left:auto; font-size:.85em; font-weight:700; white-space:nowrap; }
.map-s-competing { color:var(--red); }
.map-s-checked { color:#16a34a; }
.map-s-route { color:#2563eb; }
.map-s-holding, .map-s-staging { padding:.1em .55em; border-radius:1em; font-size:.92em; letter-spacing:.02em; }
.map-s-holding { color:#92400e; background:#fde68a; }  /* Called to Holding: amber */
.map-s-staging { color:#5b21b6; background:#ddd6fe; }  /* In Staging: violet */
[data-theme="dark"] .map-s-holding { color:#fde68a; background:#78350f; }
[data-theme="dark"] .map-s-staging { color:#ddd6fe; background:#4c1d95; }
.map-match-team { overflow-wrap:anywhere; line-height:1.2; padding-left:.5em; border-left:3px solid transparent; }
.map-match-blue { border-left-color:#2563eb; }
.map-match-red { border-left-color:var(--red); }

/* "+N more" pill pinned to the bottom of a box with matches scrolled out of view. */
.map-more {
  position:absolute; left:0; right:0; bottom:0; padding:.35em .5em; z-index:2; cursor:pointer;
  font:inherit; font-size:.9em; font-weight:700; text-align:center; color:var(--text);
  background:linear-gradient(to top, var(--panel) 60%, transparent); border:0;
}
.map-more[hidden] { display:none; }
.map-more:hover { color:var(--red); }
.map-editing .map-more { display:none; }

/* Editing */
.map-editing .map-el { cursor:move; border-style:dashed; user-select:none; touch-action:none; }
.map-editing .map-match { pointer-events:none; }
.map-editing .map-el-body { overflow:hidden; }
/* Stacking while editing: boxes can overlap, so the one being worked on must sit
   above its neighbours, and a resize handle belongs to its own box (z-index:auto
   keeps it inside that box's layer instead of poking through the others). */
.map-editing .map-el { z-index:1; }
.map-editing .map-selected { z-index:10; }
.map-selected { outline:2px solid var(--red); outline-offset:2px; }
.map-resize { display:none; position:absolute; right:0; bottom:0; width:1.8em; height:1.8em; min-width:16px; min-height:16px; cursor:nwse-resize; }
.map-editing .map-resize { display:block; background:linear-gradient(135deg, transparent 50%, var(--red) 50%); }

/* Narrow screens (.map-small, set from the stage width): the same floor plan,
   just edge to edge and taller, with each box's cards boiled down to the
   essentials — match number, teams and a status dot — so they fit. Pinch to
   zoom in for detail. */
.map-small .map-stage { padding:0 0 16px; }
.map-small .map-canvas { aspect-ratio:2 / 3; max-width:none; border-left:0; border-right:0; border-radius:0; }
.map-small .map-el { font-size:clamp(6px, 2.35cqw, 12px); border-width:1.5px; border-radius:1.2cqw; }
.map-small .map-el-head { padding:.3em .45em; letter-spacing:0; gap:.3em; }
.map-small .map-el-count:not(:empty) { min-width:1.3em; padding:.05em .3em; }
.map-small .map-el-body { padding:.22em; gap:.22em; grid-template-columns:repeat(auto-fill, minmax(min(12em, 100%), 1fr)); }
.map-small .map-match { font-size:.82em; padding:.22em .28em; gap:.08em; border-radius:.35em; }
.map-small .map-match-div, .map-small .map-match-ring { display:none; }
.map-small .map-match-top { flex-wrap:nowrap; justify-content:space-between; gap:.2em; font-size:1em; }
.map-small .map-match-status { margin-left:0; font-size:0; }
.map-small .map-s-holding, .map-small .map-s-staging { padding:0; background:none; }
.map-small .map-match-status::before {
  content:''; display:inline-block; width:.7em; height:.7em; border-radius:50%; background:currentColor;
}
.map-small .map-match-team { padding-left:.3em; border-left-width:2px; line-height:1.15; }
.map-small .map-el-empty { font-size:.9em; letter-spacing:0; }

@media print { #mapTab { display:none !important; } }

.tab[hidden] { display:none; }
.tabs[hidden] { display:none; }
