/* seerah-models · the Ḥijāz survey map sheet.
   Shared by the seven model pages (via the shell) and the gate. The sheet is
   the atlas dialog's sibling: ink ground, bone lines, brass for the field you
   stand on. Distances are compressed; the sheet says so. */

dialog.hmap {
  /* the sheet carries its own instrument palette: warm ink and brass, the
     model pages' language — the gate keeps its verdigris chrome outside */
  --bg: #14120f; --sheet: #1c1915; --bone: #ece8df; --bone-soft: #ded7c7;
  --muted: rgba(236, 232, 223, 0.62); --faint: rgba(236, 232, 223, 0.38);
  --brass: #c8a84b; --brass-soft: #d6b75a;
  --line: rgba(236, 232, 223, 0.14); --line-soft: rgba(236, 232, 223, 0.08);
  --radius-sm: 8px; --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Archivo", "Helvetica Neue", sans-serif;
  --arabic: "Amiri", "Cormorant Garamond", serif;
  --urdu: "Noto Nastaliq Urdu", "Archivo", serif;

  position: fixed; inset: 0; z-index: 100;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--bone);
  overflow: hidden;
}
dialog.hmap::backdrop { background: rgba(10, 8, 6, 0.65); }
dialog.hmap:focus-visible,
.hmap-sheet:focus-visible { outline: none; }

.hmap-sheet {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 26px calc(16px + env(safe-area-inset-bottom));
  max-width: 1060px; margin: 0 auto;
}

.hmap-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.hmap-heading { min-width: 0; }
.hmap-kicker {
  margin: 0 0 6px; font-family: var(--sans); font-size: 11px; font-weight: 500;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--faint);
}
.hmap-kicker svg { width: 13px; height: 15px; vertical-align: -2px; margin-right: 8px; }
.hmap-title {
  margin: 0; font-family: var(--serif); font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 400; line-height: 1.04; letter-spacing: 0.01em;
}
.hmap-note {
  margin: 8px 0 0; font-family: var(--sans); font-size: 12.5px; color: var(--muted);
}
body.is-ur .hmap-note { font-family: var(--urdu); font-size: 12.5px; line-height: 1.9; }
/* the field you stand on, said once in the head like a plate caption */
.hmap-here { display: flex; align-items: baseline; gap: 12px; margin-top: 10px; min-width: 0; }
.hmap-here-year {
  font-family: var(--sans); font-size: 11px; font-weight: 500; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--brass-soft); white-space: nowrap;
}
.hmap-here-name {
  font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1;
  color: var(--bone); white-space: nowrap;
}
.hmap-here-name .hmap-here-ar { font-family: var(--arabic); font-size: 17px; color: var(--muted); margin-left: 0.4em; }
.hmap-here-place { font-family: var(--sans); font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.is-ur .hmap-here-name { font-family: var(--urdu); font-size: 19px; }
body.is-ur .hmap-here-place { font-family: var(--urdu); }

/* the mode control: your field ↔ the whole road */
.hmap-mode {
  flex: 0 0 auto; height: 40px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-family: var(--sans); font-size: 12.5px; cursor: pointer; white-space: nowrap;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.hmap-mode:hover { border-color: var(--brass); color: var(--bone); }
.hmap-3d { border-color: rgba(200, 168, 75, 0.45); color: var(--brass-soft); }
.hmap-3d:hover { background: var(--brass-wash); border-color: var(--brass); color: var(--bone); }
.hmap-head-actions { display: flex; gap: 8px; flex: 0 0 auto; align-items: center; }
.hmap-close {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: transparent; color: var(--bone);
  cursor: pointer; display: grid; place-items: center;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.hmap-close:hover { border-color: var(--brass); color: var(--brass-soft); }
.hmap-close svg { width: 14px; height: 14px; }

/* the sheet itself */
.hmap-frame {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 14px 0 6px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.hmap-svg { width: 100%; height: 100%; min-height: 0; touch-action: none; cursor: grab; }
.hmap-svg.is-grabbing { cursor: grabbing; }
.hmap-svg .hmap-hit { cursor: pointer; }

.hmap-foot {
  display: flex; justify-content: space-between; gap: 18px; align-items: baseline;
  border-top: 1px solid var(--line-soft); padding-top: 10px;
  font-family: var(--sans); font-size: 11.5px; color: var(--faint);
}
.hmap-foot p { margin: 0; }
body.is-ur .hmap-foot p { font-family: var(--urdu); line-height: 1.9; }

/* ------------------------------ the drawing */
.hmap-land { fill: #191611; }
.hmap-sea { fill: #0e1114; }
.hmap-coast { fill: none; stroke: rgba(236, 232, 223, 0.55); stroke-width: 1.2; stroke-linejoin: round; }
/* water-lining: the surveyor's hand, two quiet echoes inside the coast */
.hmap-lining { fill: none; stroke: rgba(236, 232, 223, 0.16); stroke-width: 0.9; }
.hmap-lining2 { stroke: rgba(236, 232, 223, 0.08); }
.hmap-dunes path { stroke: rgba(236, 232, 223, 0.14); stroke-width: 1; fill: none; stroke-linecap: round; }
.hmap-road { fill: none; stroke: rgba(236, 232, 223, 0.5); stroke-width: 1.3; stroke-linecap: round; }
.hmap-road-t { font-family: var(--sans); font-size: 11px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; fill: rgba(236, 232, 223, 0.44); }
.hmap-svg[lang="ur"] .hmap-road-t { letter-spacing: 0; }
.hmap-spur { fill: none; stroke: rgba(236, 232, 223, 0.34); stroke-width: 1.1; stroke-dasharray: 3 3.4; }
.hmap-break { stroke: rgba(236, 232, 223, 0.5); stroke-width: 1.1; fill: none; }
.hmap-wadi { stroke: rgba(236, 232, 223, 0.26); stroke-width: 1; fill: none; }
.hmap-hill { stroke: rgba(236, 232, 223, 0.4); stroke-width: 1.1; fill: none; stroke-linecap: round; }
.hmap-dot { fill: rgba(236, 232, 223, 0.55); }
.hmap-leader { stroke: rgba(200, 168, 75, 0.4); stroke-width: 0.8; fill: none; }
/* the drawn plate: hairline frame with corner ticks */
.hmap-plate rect { fill: none; stroke: var(--line-soft); stroke-width: 1; }
.hmap-plate path { stroke: var(--line); stroke-width: 1; fill: none; }

/* the Hijrah: brass dashed — the journey is the accent, never decoration */
.hmap-hijrah {
  fill: none; stroke: var(--brass); stroke-width: 1.5;
  stroke-dasharray: 5 4; stroke-linecap: round;
}
.hmap-hijrah-t { font-family: var(--sans); font-size: 10.5px; font-weight: 500; fill: var(--brass-soft); letter-spacing: 0.04em; }
.hmap-hijrah-ar { font-family: var(--arabic); font-size: 12.5px; fill: var(--brass-soft); }
.hmap-route-hit { fill: transparent; pointer-events: all; }
.hmap-route.is-here .hmap-hijrah-t,
.hmap-route.is-here .hmap-hijrah-ar { fill: #f2d99a; }

.hmap-city circle { fill: none; stroke: rgba(236, 232, 223, 0.66); stroke-width: 1.3; }
.hmap-en { font-family: var(--sans); font-size: 11px; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; fill: rgba(236, 232, 223, 0.78); }
.hmap-city-t { font-size: 10.5px; font-weight: 500; }
.hmap-ar { font-family: var(--arabic); font-size: 13px; fill: rgba(236, 232, 223, 0.55); }
.hmap-tiny { font-family: var(--sans); font-size: 11px; letter-spacing: 0.06em; fill: rgba(236, 232, 223, 0.45); text-transform: uppercase; }
/* sea names are set in italic serif, the way charts set them */
.hmap-sea-t { font-family: var(--serif); font-style: italic; font-size: 14px; letter-spacing: 0.22em; fill: rgba(236, 232, 223, 0.4); }
.hmap-sea-ar { font-family: var(--arabic); font-size: 13px; fill: rgba(236, 232, 223, 0.34); }
.hmap-north { stroke: rgba(236, 232, 223, 0.45); stroke-width: 1.1; fill: none; }
.hmap-north-t { font-family: var(--sans); font-size: 11px; fill: rgba(236, 232, 223, 0.45); }
.hmap-inset rect { fill: #161310; stroke: var(--line); }
.hmap-inset .hmap-road { stroke: rgba(236, 232, 223, 0.42); }

/* field markers: brass diamonds; the field you stand on is filled and ringed */
.hmap-m { transition: opacity 320ms var(--ease); }
.hmap-hit { cursor: pointer; outline: none; }
.hmap-g {
  fill: rgba(20, 18, 15, 0.85); stroke: var(--brass); stroke-width: 1.4;
  transition: fill 180ms var(--ease), stroke 180ms var(--ease);
}
.hmap-field .hmap-en { fill: rgba(236, 232, 223, 0.86); }
.hmap-hit:hover .hmap-g,
.hmap-hit:focus-visible .hmap-g { fill: var(--brass); stroke: var(--brass-soft); }
.hmap-hit:focus-visible { outline: none; }
.hmap-hit:focus-visible + .hmap-en { fill: var(--brass-soft); }
.hmap-field.is-here .hmap-g { fill: var(--brass); stroke: var(--brass-soft); }
.hmap-field.is-here .hmap-en { fill: var(--brass-soft); }
.hmap-field.is-here .hmap-ar { fill: var(--brass-soft); }

/* focus: the sheet has travelled to the field you stand on — every other
   mark steps back, the field stays lit */
.hmap-svg.has-focus .hmap-m:not(.is-here),
.hmap-svg.has-focus .hmap-city { opacity: 0.34; }
.hmap-svg.has-focus .hmap-inset { opacity: 0.34; }
.hmap-svg.has-focus .hmap-inset.is-here-host { opacity: 1; }
.hmap-svg.has-focus .hmap-dunes { opacity: 0.5; }
.hmap-svg.has-focus .hmap-road-t { opacity: 0.5; }
.hmap-svg.has-focus .hmap-field.is-here { opacity: 1; }
/* focused on the road: the other fields are not context, they are noise.
   Makkah stays: it is where the road begins. */
.hmap-svg.has-focus.is-route .hmap-m:not(.is-here):not([data-key="makkah"]) { opacity: 0; }
.hmap-svg.has-focus.is-route .hmap-field[data-key="makkah"] { opacity: 0.55; }
.hmap-svg.has-focus.is-route .hmap-road-t { opacity: 0; }
.hmap-svg.has-focus .hmap-sea-t,
.hmap-svg.has-focus .hmap-sea-ar { opacity: 0.6; }

/* Urdu: the latin line gives way to Nastaliq */
.hmap-svg[lang="ur"] .hmap-en,
.hmap-svg[lang="ur"] .hmap-city-t,
.hmap-svg[lang="ur"] .hmap-tiny,
.hmap-svg[lang="ur"] .hmap-sea-t,
.hmap-svg[lang="ur"] .hmap-hijrah-t,
.hmap-svg[lang="ur"] .hmap-north-t {
  font-family: var(--urdu); text-transform: none; letter-spacing: 0;
  font-size: 12.5px; font-weight: 400;
}
.hmap-svg[lang="ur"] .hmap-tiny,
.hmap-svg[lang="ur"] .hmap-sea-t { font-size: 12px; }

/* the map tool in the bar matches the battles tool */
.tool-map svg { width: 15px; height: 15px; }
/* on a narrow bar the map goes icon-only, like the bar's other tools */
@media (max-width: 480px) {
  /* three controls in a 320px head: wrap rather than clip the first button */
  .hmap-head-actions { flex-wrap: wrap; }
  .hmap-mode { height: 34px; padding: 0 9px; font-size: 11px; }
  .hmap-close { width: 34px; height: 34px; }
  .tool-map span { display: none; }
  .tool-map { padding: 0 9px; }
}

@media (max-width: 700px) {
  .hmap-sheet { padding: calc(12px + env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom)); }
  /* the head stacks on a phone: title first, the controls beneath it, so the
     actions never squeeze the plate into a column of single words */
  .hmap-head { flex-direction: column; align-items: stretch; gap: 9px; }
  .hmap-head-actions { justify-content: flex-end; }
  .hmap-kicker { display: none; }
  .hmap-title { font-size: 22px; line-height: 1.08; }
  .hmap-note { display: none; }
  .hmap-here { margin-top: 7px; gap: 8px; }
  .hmap-here-name { font-size: 18px; }
  .hmap-mode { height: 36px; padding: 0 10px; font-size: 11.5px; }
  .hmap-close { width: 36px; height: 36px; }
  /* the viewBox zoom carries the framing: the sheet fills the phone at every
     depth, so nothing pans and nothing needs a scroll rail */
  .hmap-frame { overflow: hidden; align-items: center; padding: 8px 0; }
  .hmap-svg { height: 100%; width: 100%; }
  .hmap-foot { flex-direction: column; gap: 2px; margin-top: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .hmap-m, .hmap-g { transition: none; }
}
