/* ==========================================================================
   Blackfire society maps — css/map.css (property-map.html only)
   Load after css/style.css and css/bf-tools.css; uses their tokens (--accent, --ink, --rule,
   --stone, --ash, --paper). MapLibre's own stylesheet is added by js/property-map.js only when
   the map loads; the overrides below are scoped to .pm-map so they do nothing until then.
   ========================================================================== */

.page-map {
  --pm-approx-bg: #fff4e5;
  --pm-approx-line: #d9a75b;
  --pm-approx-ink: #6b4500;
  --pm-none-bg: #f1f1ef;
  --pm-sel-bg: #fff3ee;
}

/* Keep a focused control clear of the sticky header and the fixed "Ask Blackfire" button. */
.pm-app button, .pm-app select, .pm-app input, .pm-app a, .pm-app [tabindex] {
  scroll-margin-top: 100px;
  scroll-margin-bottom: 90px;
}
.pm-app, .pm-app > *, .pm-layout > *, .pm-col-side > * { min-width: 0; }

.pm-vh {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- page title --------------------------------------------------------- */
.pm-title { padding-bottom: 28px; }
.pm-title .lead { max-width: 780px; }
.pm-keypoints {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.pm-keypoints li {
  margin: 0; padding: 10px 14px; background: var(--ash);
  border-left: 3px solid var(--accent); font-size: 15px; line-height: 1.45;
}

/* ---- messages ----------------------------------------------------------- */
.pm-section { padding-top: 32px; }
.pm-msg { margin: 0 0 18px; padding: 10px 14px; background: var(--ash); border-left: 3px solid var(--stone); font-size: 15px; }
.pm-msg--note { border-left-color: var(--pm-approx-line); background: var(--pm-approx-bg); }
.pm-msg--error { border-left-color: var(--bf-error, #b3261e); background: var(--bf-error-bg, #fff6f5); }
.pm-linkbtn {
  font: inherit; color: var(--ink); background: none; border: 0; padding: 0 2px; min-height: 44px;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600;
}
.pm-linkbtn:hover { color: var(--accent); }
/* "Go to the list" in the society card: only where the list sits below the map (see 900px rule). */
.pm-to-list { display: none; }

/* ---- controls ----------------------------------------------------------- */
.pm-controls {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px;
  margin: 0 0 28px; padding: 18px; background: var(--ash); border: 1px solid var(--rule);
}
.pm-controls .field span { color: var(--graphite); font-weight: 600; font-size: 14px; }
.pm-controls select, .pm-controls input[type="search"] {
  font: inherit; font-size: 16px; color: var(--ink); width: 100%; min-height: 46px;
  padding: 9px 10px; border: 1px solid #b9b9b4; border-radius: 3px; background: #fff;
}
.pm-controls select:disabled, .pm-controls input:disabled { background: #f7f7f5; color: var(--stone); }
.pm-controls input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* ---- layout: list | map + card ------------------------------------------ */
.pm-layout {
  display: grid; gap: 32px; align-items: start;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas: "list side";
}
.pm-col-list { grid-area: list; }
.pm-col-side { grid-area: side; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.pm-h { font-size: 24px; margin-bottom: 6px; }
.pm-count { margin: 0 0 14px; color: var(--stone); font-size: 15px; }
#pm-list-title:focus { outline: none; }
#pm-list-title:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---- block / society list ----------------------------------------------- */
.pm-blocks, .pm-societies {
  list-style: none; margin: 0 0 22px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
}
.pm-societies { grid-template-columns: minmax(0, 1fr); }
.pm-blocks li, .pm-societies li { margin: 0; }
.pm-group { font-size: 17px; margin: 18px 0 8px; color: var(--graphite); }
.pm-group:first-child { margin-top: 0; }
.pm-item {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  width: 100%; min-height: 52px; padding: 8px 12px; text-align: left;
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 3px; cursor: pointer;
}
.pm-item:hover { border-color: var(--ink); }
.pm-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pm-item[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--pm-sel-bg); }
.pm-item-name { font-weight: 600; font-size: 16px; line-height: 1.25; }
.pm-item-meta { font-size: 13.5px; color: var(--stone); line-height: 1.3; }
.pm-empty { color: var(--stone); }

/* static (no-JavaScript) copy */
.pm-static-note { font-size: 15px; color: var(--stone); }
.pm-static-society { border-top: 1px solid var(--rule); padding: 4px 0; }
.pm-static-society summary { min-height: 44px; display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }
.pm-static-society h3 { font-size: 15px; margin: 10px 0 4px; color: var(--graphite); }
.pm-static-list { margin: 0 0 8px; padding-left: 1.2em; columns: 2; column-gap: 24px; font-size: 15px; }
.pm-static-list li { break-inside: avoid; }

/* ---- CDA schematic grid -------------------------------------------------- */
.pm-cda { border: 1px solid var(--rule); background: var(--paper); padding: 14px 16px 10px; }
.pm-cda-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 6px; }
.pm-cda-head h2 { font-size: 20px; margin: 0; }
.pm-cda-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 4px; }
.pm-cda-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pm-cda-svg { display: block; width: 100%; height: auto; min-width: var(--pm-cda-min, 640px); max-width: 760px; font-family: var(--font); }
.pm-cda-axis { font-size: 12px; fill: var(--stone); }
.pm-cda-empty { fill: none; stroke: #d6d6d1; stroke-dasharray: 3 3; }
.pm-cda-cell { cursor: pointer; outline: none; }
.pm-cda-cell rect { fill: #ffffff; stroke: #8f8f8a; stroke-width: 1.2; }
.pm-cda-cell text { font-size: 13px; font-weight: 600; fill: var(--ink); pointer-events: none; }
.pm-cda-cell:hover rect { stroke: var(--ink); stroke-width: 2; }
.pm-cda-cell.is-dim rect { fill: #f3f3f1; stroke: #cfcfca; }
.pm-cda-cell.is-dim text { fill: #9a9a96; }
.pm-cda-cell.is-selected rect { fill: var(--accent); stroke: var(--ink); stroke-width: 2; }
.pm-cda-cell.is-selected text { fill: #ffffff; }
.pm-cda-cell:focus-visible rect { stroke: var(--ink); stroke-width: 3.5; }
.pm-cda-note { font-size: 14px; color: var(--stone); margin: 6px 0 0; }
.pm-cda-note:empty { display: none; }
.pm-cda-picked { margin: 6px 0 0; font-size: 15px; }

/* ---- map panel ----------------------------------------------------------- */
.pm-map-panel .pm-h { margin-bottom: 10px; }
.pm-map-frame {
  position: relative; height: 440px; background: var(--ash);
  border: 1px solid var(--rule); overflow: hidden;
}
/* MapLibre's stylesheet sets .maplibregl-map { position: relative }; the size must survive that. */
.pm-map, .pm-map-frame > .pm-map.maplibregl-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.pm-map-frame[data-state="failed"] { height: auto; min-height: 0; }
.pm-map-frame[data-state="failed"] .pm-map { display: none; }
.pm-overlay {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--ash); text-align: center;
}
.pm-map-frame[data-state="failed"] .pm-overlay { position: static; text-align: left; justify-content: flex-start; }
.pm-overlay-msg { max-width: 460px; margin: 0; font-size: 15px; }
.pm-overlay-msg p { margin: 0 0 12px; }
.pm-map-frame[data-state="failed"] .pm-overlay-msg { max-width: none; border-left: 3px solid var(--bf-error, #b3261e); padding-left: 14px; }
.pm-tile-warn {
  position: absolute; left: 10px; right: 64px; top: 10px; z-index: 4;
  background: rgba(255, 255, 255, .95); border-left: 3px solid var(--pm-approx-line);
  padding: 4px 10px; font-size: 14px;
}
.pm-attrib { margin: 8px 0 0; font-size: 13px; color: var(--stone); line-height: 1.45; }
.pm-attrib a { text-decoration: underline; text-underline-offset: 2px; }
.pm-pin-note { margin: 6px 0 0; font-size: 14.5px; line-height: 1.45; }

/* fullscreen: the frame (map + messages) fills the screen */
.pm-map-frame:fullscreen { height: 100vh; border: 0; }

/* MapLibre controls: at least 44 px to tap */
.pm-map .maplibregl-ctrl-group button { width: 44px; height: 44px; }
.pm-map .maplibregl-ctrl-group button + button { border-top-color: var(--rule); }
.pm-map .maplibregl-ctrl-attrib { font-size: 12px; line-height: 1.5; max-width: calc(100% - 20px); }
.pm-map .maplibregl-ctrl-attrib a { text-decoration: underline; }
.pm-map .maplibregl-cooperative-gesture-screen { font-size: 17px; }
.pm-map .maplibregl-popup-content { font-family: var(--font); font-size: 14px; line-height: 1.4; padding: 12px 44px 12px 12px; }
.pm-map .maplibregl-popup-close-button { width: 44px; height: 44px; font-size: 22px; }

/* pins: 44 px tap area around a drawn marker */
.pm-pin {
  width: 44px; height: 44px; padding: 0; margin: 0; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
}
.pm-pin::before {
  content: ""; width: 22px; height: 22px; margin-bottom: 9px;
  background: var(--fire); border: 2px solid #fff; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
.pm-pin.is-dim::before { background: #8d8d88; }
.pm-pin.is-active::before { background: var(--ink); width: 26px; height: 26px; }
.pm-pin:focus-visible { outline: 3px solid var(--ink); outline-offset: -4px; border-radius: 50%; }

/* ---- details card -------------------------------------------------------- */
.pm-card {
  background: var(--paper); border: 1px solid var(--rule); border-top: 4px solid var(--accent);
  padding: 18px 20px 16px;
}
.pm-card-title { font-size: 26px; margin-bottom: 2px; }
.pm-card-title:focus { outline: none; }
.pm-card-title:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.pm-card-sub { color: var(--stone); margin-bottom: 12px; }
.pm-card-h { font-size: 17px; margin: 18px 0 6px; padding-top: 12px; border-top: 1px solid var(--rule); }
.pm-facts { margin: 0 0 6px; display: grid; gap: 0; }
.pm-facts > div { display: grid; grid-template-columns: minmax(130px, 34%) minmax(0, 1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid #ececea; }
.pm-facts dt { font-weight: 600; font-size: 14.5px; color: var(--graphite); }
.pm-facts dd { margin: 0; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.pm-card a:not(.btn), .pm-about a, .pm-pin-note a, .pm-msg a { text-decoration: underline; text-underline-offset: 3px; }
.pm-small { font-size: 14.5px; color: var(--graphite); line-height: 1.5; }
.pm-card .btn-row { margin: 16px 0 8px; }
.pm-card .btn-small, .pm-app .btn-small { min-height: 44px; display: inline-flex; align-items: center; }
.pm-linkbox { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 14px; color: var(--stone); }
.pm-linkrow { display: flex; gap: 8px; }
.pm-linkrow input { flex: 1; min-width: 0; min-height: 44px; font-size: 14px; }

/* tags */
.pm-tag {
  display: inline-block; padding: 1px 8px; margin-right: 2px; border-radius: 12px;
  font-size: 12.5px; font-weight: 600; line-height: 1.6; white-space: nowrap; vertical-align: 1px;
  background: var(--pm-none-bg); border: 1px solid var(--rule); color: var(--graphite);
}
.pm-tag--approx { background: var(--pm-approx-bg); border-color: var(--pm-approx-line); color: var(--pm-approx-ink); }
.pm-tag--third { background: #f4f4f2; border-color: #c9c9c4; }
.pm-tag--ok { background: #eef7ef; border-color: #8cc196; color: #1f5a2a; }
.pm-check { font-size: 14px; color: var(--stone); }

/* ---- third-party references and the explanation -------------------------- */
.pm-refs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pm-refs li { margin: 0; padding: 12px 14px; background: var(--paper); border: 1px solid var(--rule); line-height: 1.7; }
.pm-refs strong { display: block; }
.pm-ext-link { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; display: inline-flex; align-items: center; min-height: 44px; }
.pm-about { max-width: 860px; }
.pm-about dl { margin: 0 0 18px; }
.pm-about dt { font-weight: 700; margin-top: 14px; }
.pm-about dd { margin: 4px 0 0; }

/* ---- phones -------------------------------------------------------------- */
@media (max-width: 1024px) {
  .pm-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .pm-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "list"; gap: 28px; }
  .pm-to-list { display: inline-flex; align-items: center; text-align: left; }
  .pm-keypoints { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
@media (max-width: 600px) {
  .pm-controls { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .pm-map-frame { height: min(62vh, 400px); min-height: 300px; }
  .pm-facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .pm-static-list { columns: 1; }
  .pm-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pm-card { padding: 16px 14px 14px; }
  .pm-card-title { font-size: 23px; }
  .pm-linkrow { flex-direction: column; }
}

@media print {
  .pm-controls, .pm-map-panel, .pm-cda, .pm-card .btn-row, .pm-linkbox { display: none !important; }
}
