/* Map page. Loaded only by docs/map/index.md (hooks/map_page.py adds the link).
   Sizes are in px on purpose: the theme scales rem with the viewport, and the picture
   has to keep its column widths. Colours come from the theme except the two fills. */

.md-main__inner.md-grid:has(.mss-map) { max-width: 1400px; }

.mss-map {
  --map-scene: #eef3ee;
  --map-scene-line: #b9cbb9;
  --map-asset: #f7f1e6;
  --map-asset-line: #dccba6;
  --map-step: #eef1f6;
  --map-step-line: #bcc6d6;
  --map-line: var(--md-default-fg-color--lighter);
  --map-muted: var(--md-default-fg-color--light);
  --map-cw: 208px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 28px;
  align-items: start;
  margin-top: 20px;
  font-size: 14px;
  line-height: 1.45;
}
[data-md-color-scheme="slate"] .mss-map {
  --map-scene: #25302a;
  --map-scene-line: #47594c;
  --map-asset: #332d22;
  --map-asset-line: #5e5338;
  --map-step: #262b33;
  --map-step-line: #4a5567;
}

.mss-map .map-main { min-width: 0; }
.mss-map .map-bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 18px; }
.mss-map .map-views { display: inline-flex; border: 1px solid var(--map-line); border-radius: 6px; overflow: hidden; }
.mss-map .map-view {
  font: inherit; font-size: 13.5px; cursor: pointer; padding: 6px 13px;
  color: var(--map-muted); background: var(--md-default-bg-color); border: 0;
}
.mss-map .map-view + .map-view { border-left: 1px solid var(--map-line); }
.mss-map .map-view:hover { color: var(--md-default-fg-color); }
.mss-map .map-view:focus-visible { outline: 2px solid var(--md-accent-fg-color); outline-offset: -2px; }
.mss-map .map-view.is-on { color: var(--md-default-fg-color); background: var(--md-code-bg-color); font-weight: 500; }
.mss-map .map-count { color: var(--md-accent-fg-color); font-weight: 500; }
.mss-map .map-search {
  flex: 1 1 240px; min-width: 0; max-width: 420px; font: inherit; font-size: 13.5px; padding: 6px 10px;
  color: var(--md-default-fg-color); background: var(--md-default-bg-color);
  border: 1px solid var(--map-line); border-radius: 6px;
}
.mss-map .map-search::placeholder { color: var(--map-muted); opacity: 1; }
.mss-map .map-search:focus { outline: 2px solid var(--md-accent-fg-color); outline-offset: 0; border-color: transparent; }

.mss-map .map-pic { min-width: 0; display: grid; gap: 14px; }
.mss-map .map-heads,
.mss-map .map-row { display: grid; grid-template-columns: var(--map-cw) 88px var(--map-cw) 88px var(--map-cw); align-items: start; }
.mss-map .map-heads { align-items: end; }
.mss-map .map-heads div,
.mss-map .map-cross-title,
.mss-map .map-h { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--map-muted); }
.mss-map .map-heads .map-h-asset { grid-column: 3 / 6; }

.mss-map .map-box {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font: inherit; color: var(--md-default-fg-color);
  background: var(--md-default-bg-color); border: 1px solid var(--map-line); border-radius: 6px; padding: 10px 12px;
}
.mss-map .map-box.is-scene { background: var(--map-scene); border-color: var(--map-scene-line); }
.mss-map .map-box.is-asset { background: var(--map-asset); border-color: var(--map-asset-line); }
.mss-map .map-box.is-step { background: var(--map-step); border-color: var(--map-step-line); }
.mss-map .map-box.is-optional { border-style: dashed; }
.mss-map .map-pic.is-searching .map-box:not(.is-hit):not(.is-selected) { opacity: .38; }
.mss-map .map-box.is-hit { border-color: var(--md-accent-fg-color); border-style: solid; }
.mss-map .map-box:hover { border-color: var(--md-accent-fg-color); }
.mss-map .map-box:focus-visible { outline: 2px solid var(--md-accent-fg-color); outline-offset: 2px; }
.mss-map .map-box.is-selected { border-color: var(--md-accent-fg-color); box-shadow: 0 0 0 2px var(--md-accent-fg-color); }
.mss-map .map-box .map-name { display: block; font-weight: 500; font-size: 15px; }
.mss-map .map-box .map-line { display: block; color: var(--map-muted); font-size: 12.5px; line-height: 1.3; margin-top: 2px; }
.mss-map .map-box .map-step { display: block; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--map-muted); margin-bottom: 3px; }

.mss-map .map-stack { display: grid; gap: 6px; padding-left: 10px; border-left: 2px solid var(--map-asset-line); }
.mss-map .map-stack .map-box { padding: 7px 10px; }
.mss-map .map-stack .map-name { font-size: 14px; }

.mss-map .map-via { text-align: center; font-size: 12px; color: var(--map-muted); position: relative; padding: 0 6px 12px; margin-top: 12px; }
.mss-map .map-via::after { content: ""; position: absolute; left: 6px; right: 12px; bottom: 6px; border-top: 1.5px solid var(--map-muted); }
.mss-map .map-via::before { content: ""; position: absolute; right: 6px; bottom: 2px; border-left: 7px solid var(--map-muted); border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; }

.mss-map .map-cross { margin-top: 10px; }
.mss-map .map-cross-title { margin-bottom: 8px; }
.mss-map .map-cross-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }

.mss-map .map-detail {
  min-width: 0; position: sticky; top: 72px;
  border: 1px solid var(--map-line); border-radius: 6px; padding: 16px 18px 18px;
  background: var(--md-code-bg-color);
}
.mss-map .map-tag { font-size: 12px; color: var(--map-muted); }
.md-typeset .mss-map .map-title { font-size: 20px; font-weight: 500; line-height: 1.25; margin: 2px 0 8px; color: var(--md-default-fg-color); }
.md-typeset .mss-map .map-sum { margin: 0 0 12px; }
.mss-map .map-h { margin: 14px 0 5px; }
.md-typeset .mss-map .map-h a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.md-typeset .mss-map .map-where { margin: 0; }
.md-typeset .mss-map .map-where code,
.md-typeset .mss-map .map-tag code { font-size: 11.5px; overflow-wrap: anywhere; }
.md-typeset .mss-map .map-list,
.md-typeset .mss-map .map-steps { margin: 0; padding: 0; display: grid; gap: 5px; }
.md-typeset .mss-map .map-list { list-style: none; }
.md-typeset .mss-map .map-list li { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.md-typeset .mss-map .map-steps { padding-left: 20px; gap: 6px; }
.md-typeset .mss-map .map-steps li { margin: 0; }
.mss-map .map-list small { color: var(--map-muted); font-size: 11.5px; }
.mss-map .map-jump { font: inherit; border: 0; background: none; padding: 0; cursor: pointer; color: var(--md-typeset-a-color); text-decoration: underline; text-underline-offset: 2px; }
.mss-map .map-back { display: block; font-size: 12.5px; margin-bottom: 10px; }
.mss-map .map-results li { display: block; }
.mss-map .map-results small { display: block; }
.mss-map .map-in .map-jump { font-size: inherit; }
.md-typeset .mss-map .map-go { margin-top: 16px; font-size: 13px; padding: 6px 14px; }

@media (max-width: 1180px) {
  .mss-map { grid-template-columns: minmax(0, 1fr); }
  .mss-map .map-detail { position: static; }
}
@media (max-width: 760px) {
  .mss-map .map-heads { display: none; }
  .mss-map .map-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .mss-map .map-row > * { margin-left: calc(var(--map-depth, 0) * 18px); width: calc(100% - var(--map-depth, 0) * 18px); }
  /* A sequence is not a nesting, so the steps of the second picture stay flush. */
  .mss-map .map-pic[data-picture="loop"] .map-row > * { margin-left: 0; width: 100%; }
  .mss-map .map-via { text-align: left; padding: 2px 0; margin-top: 0; }
  .mss-map .map-via::after,
  .mss-map .map-via::before { content: none; }
  .mss-map .map-via span::before { content: "\2193\00a0"; }
}
