/* ==========================================================================
   Planning constraints map — self-contained component.
   Every value below is an existing design-system token (assets/css/style.css)
   with a literal fallback, so the block renders correctly on a page that has
   not inlined the stylesheet. No new colour, font, radius or button family.
   ========================================================================== */

.ad-cmap {
  --cmap-ca: var(--accent, #2563EB);
  --cmap-ca-fill: rgba(37, 99, 235, 0.16);
  --cmap-a4: var(--warn, #D4A547);
  --cmap-a4-fill: rgba(212, 165, 71, 0.22);
  position: relative;
}

.ad-cmap-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* ---------- map panel ---------- */

.ad-cmap-stage {
  position: relative;
  background: linear-gradient(160deg, #fff 0%, rgba(245, 248, 255, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-lg, 24px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(11, 18, 34, 0.07), 0 4px 14px rgba(11, 18, 34, 0.05));
  overflow: hidden;
}

.ad-cmap-view { position: relative; }

.ad-cmap-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  background: var(--bg-2, #EBF0FB);
  /* One-finger drag scrolls the PAGE until the reader engages the map. */
  touch-action: pan-y;
  cursor: default;
}
.ad-cmap.is-engaged .ad-cmap-canvas { touch-action: none; cursor: grab; }
.ad-cmap.is-engaged .ad-cmap-canvas:active { cursor: grabbing; }

.ad-cmap-outline { fill: var(--surface, #fff); stroke: var(--line-strong, rgba(11, 18, 34, 0.14)); stroke-width: 1.4; }
.ad-cmap-ca { fill: var(--cmap-ca-fill); stroke: var(--cmap-ca); stroke-width: 0.9; }
.ad-cmap-a4 { fill: var(--cmap-a4-fill); stroke: var(--cmap-a4); stroke-width: 0.9; }
.ad-cmap-hit { stroke: var(--ink, #0B1222); stroke-width: 2.4; }
/* The one area a page is about, when the page names it. Heavier than a hit
   because it is the answer the reader arrived for, not a search result. */
.ad-cmap-focus { stroke: var(--ink, #0B1222); stroke-width: 2.8; fill-opacity: 0.42; }
.ad-cmap-key[disabled] { opacity: 0.4; cursor: default; }
.ad-cmap-key[disabled]:hover { background: transparent; }
.ad-cmap-pin { fill: var(--ink, #0B1222); stroke: #fff; stroke-width: 2; }
.ad-cmap-layer-off { display: none; }

.ad-cmap-tools {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ad-cmap-tool {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full, 999px);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink, #0B1222);
  border: 1px solid var(--line, rgba(11, 18, 34, 0.08));
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(11, 18, 34, 0.07));
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  transition: background 0.2s var(--ease, cubic-bezier(0.22, 1, 0.36, 1)), transform 0.2s var(--ease, ease);
}
.ad-cmap-tool:hover { background: #fff; transform: translateY(-1px); }
.ad-cmap-tool[aria-pressed="true"] { background: var(--ink, #0B1222); color: var(--bg, #F5F8FF); }

.ad-cmap-veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  background: rgba(235, 240, 251, 0.72);
  color: var(--ink-soft, #3B4F72);
  font-size: 0.92rem;
}
.ad-cmap-veil[hidden] { display: none; }

.ad-cmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line, rgba(11, 18, 34, 0.08));
  background: rgba(255, 255, 255, 0.6);
}
.ad-cmap-key {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-full, 999px);
  border: 1px solid var(--line-strong, rgba(11, 18, 34, 0.14));
  background: transparent;
  color: var(--ink, #0B1222);
  font-size: 0.86rem;
  font-weight: 600;
  transition: background 0.2s var(--ease, ease), border-color 0.2s var(--ease, ease);
}
.ad-cmap-key:hover { background: rgba(11, 18, 34, 0.05); }
.ad-cmap-key[aria-pressed="false"] { color: var(--ink-softer, #56688A); opacity: 0.55; }
.ad-cmap-swatch { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; }
.ad-cmap-swatch-ca { background: var(--cmap-ca-fill); border: 1.5px solid var(--cmap-ca); }
.ad-cmap-swatch-a4 { background: var(--cmap-a4-fill); border: 1.5px solid var(--cmap-a4); }

/* ---------- answer panel ---------- */

.ad-cmap-panel {
  background: linear-gradient(160deg, #fff 0%, rgba(245, 248, 255, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-lg, 24px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(11, 18, 34, 0.07), 0 4px 14px rgba(11, 18, 34, 0.05));
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ad-cmap-form { display: flex; flex-direction: column; gap: 10px; }
.ad-cmap-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-softer, #56688A);
}
.ad-cmap-row { display: flex; gap: 10px; }
.ad-cmap-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 1rem; /* 16px — below this iOS zooms the page on focus */
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--r-sm, 10px);
  border: 1px solid var(--line-strong, rgba(11, 18, 34, 0.14));
  background: var(--surface, #fff);
  color: var(--ink, #0B1222);
}
.ad-cmap-input::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; color: var(--ink-softer, #56688A); }
.ad-cmap-input:focus { outline: 2px solid var(--accent, #2563EB); outline-offset: 2px; }
.ad-cmap-submit { min-height: 48px; }

.ad-cmap-verdict {
  border-radius: var(--r-md, 16px);
  border: 1px solid var(--line, rgba(11, 18, 34, 0.08));
  background: var(--bg-2, #EBF0FB);
  padding: 20px;
}
.ad-cmap-verdict h3 {
  font-family: var(--font-display, 'Fraunces', serif);
  font-size: 1.32rem;
  font-variation-settings: "opsz" 36;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.ad-cmap-verdict p { color: var(--ink-soft, #3B4F72); font-size: 0.95rem; line-height: 1.55; }
.ad-cmap-verdict p + p { margin-top: 10px; }

.ad-cmap-hits { display: flex; flex-direction: column; gap: 12px; }
.ad-cmap-hit-card {
  border-radius: var(--r-md, 16px);
  border: 1px solid var(--line, rgba(11, 18, 34, 0.08));
  background: var(--surface, #fff);
  padding: 16px 18px;
  border-left: 3px solid var(--line-strong, rgba(11, 18, 34, 0.14));
}
.ad-cmap-hit-card.is-ca { border-left-color: var(--cmap-ca); }
.ad-cmap-hit-card.is-a4 { border-left-color: var(--cmap-a4); }
.ad-cmap-hit-kind {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-softer, #56688A);
}
.ad-cmap-hit-card h4 {
  font-family: var(--font-display, 'Fraunces', serif);
  font-size: 1.06rem;
  font-variation-settings: "opsz" 36;
  margin: 4px 0 6px;
}
.ad-cmap-hit-card p { font-size: 0.9rem; color: var(--ink-soft, #3B4F72); line-height: 1.5; }
.ad-cmap-hit-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 14px;
  margin-top: 10px;
  font-size: 0.85rem;
}
.ad-cmap-hit-card dt { color: var(--ink-softer, #56688A); }
.ad-cmap-hit-card dd { color: var(--ink, #0B1222); font-weight: 600; }
.ad-cmap-hit-card a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-deep, #1D4ED8);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ad-cmap-note {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--ink-softer, #56688A);
  border-top: 1px solid var(--line, rgba(11, 18, 34, 0.08));
  padding-top: 14px;
}
.ad-cmap-note a { color: var(--accent-deep, #1D4ED8); text-decoration: underline; text-underline-offset: 2px; }

/* The legend is a flex row; this sits under the keys on its own line. Shown
   only where a borough has filed no Article 4 boundaries, because a greyed-out
   key reads as "there are none here" and a title attribute is invisible to
   touch. It is a statement about the register, not about the borough. */
.ad-cmap-a4note { flex: 1 1 100%; margin: 4px 0 0; border-top: none; padding-top: 0; }

.ad-cmap-cta { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 900px) {
  .ad-cmap-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .ad-cmap-panel { padding: 22px 18px; }
  .ad-cmap-canvas { aspect-ratio: 1 / 1; }
  .ad-cmap-row { flex-direction: column; }
  .ad-cmap-submit { width: 100%; justify-content: center; }
  .ad-cmap-legend { padding: 12px; }
  .ad-cmap-key { font-size: 0.8rem; padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .ad-cmap-tool, .ad-cmap-key { transition: none; }
  .ad-cmap-tool:hover { transform: none; }
}
