/* Every control outside the map has a row. Suggestions expand inside the
   search row so they cannot intercept taps on the canvas or its controls. */
.app--location {
  --map-zoom-size: 36px;
  --map-rail-gap: 10px;
}
@media (pointer: coarse) {
  .app--location { --map-zoom-size: 44px; }
}

.app--location .controls-section > .panel-body { padding: 0; }
.app--location .viewer-section .scene-caption { z-index: 11; }
.app--location .viewer-loading {
  pointer-events: none;
  box-sizing: border-box;
  padding-bottom: 52px;
}
.app--location .map-selector {
  display: grid;
  grid-template:
    "search" auto
    "status" auto
    "map" minmax(194px, 1fr)
    "warning" auto
    "rotate" auto
    "place" auto / minmax(0, 1fr);
  /* On a short screen the panel scrolls. The map keeps space for the
     three navigation buttons and the attribution below them. */
  flex: 1 0 auto;
  min-width: 0;
}
.app--location .map-selector > .search-row {
  grid-area: search;
  position: relative;
  inset: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  padding: 9px 14px;
}
.app--location .search-input { min-width: 0; width: 100%; }
.app--location .search-row > .search-list {
  position: static;
  grid-column: 1 / -1;
  max-height: min(220px, 24dvh);
  overscroll-behavior: contain;
}
.app--location .map-selector > .search-status {
  grid-area: status;
  position: static;
  margin: 0;
  padding: 0 14px 6px;
}
.app--location .map-selector > .map-wrapper {
  grid-area: map;
  position: relative;
  inset: auto;
  min-height: 0;
}
.app--location .map-wrapper > .preset-row {
  top: var(--map-rail-gap);
  right: calc(var(--map-zoom-size) + 2 * var(--map-rail-gap));
}
.app--location .map-selector .mapboxgl-ctrl-top-right,
.app--location .map-selector .leaflet-top.leaflet-right { top: 0; }
.app--location .map-selector .mapboxgl-ctrl-group > button,
.app--location .map-selector .leaflet-control-zoom a {
  width: var(--map-zoom-size);
  height: var(--map-zoom-size);
}
/* Some preview models use a scale above the logo in the lower left corner. */
.app--location .map-wrapper:has(.mapboxgl-ctrl-scale) > .map-view-switch {
  bottom: 70px;
}
.app--location .map-wrapper:has(.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-logo) .mapboxgl-ctrl-attrib.mapboxgl-compact-show {
  box-sizing: border-box;
  max-width: calc(100cqw - 122px);
}
.app--location .map-selector > .terrain-warning { grid-area: warning; }
.app--location .map-selector > .rot-row {
  grid-area: rotate;
  margin: 0;
  padding: 5px 14px;
}
.app--location .map-selector > .map-footer {
  grid-area: place;
  position: static;
  max-width: 100%;
  height: auto;
  padding: 5px 14px;
}
.app--location .map-footer .map-place-row { margin: 0; }

.app--location .map-wrapper:has(.mapboxgl-compact-show, .map-attrib:not(.map-attrib--closed)) > .map-switches {
  /* Include the height of a native horizontal scrollbar on the credit links. */
  bottom: 54px;
}
.app--location .map-wrapper .mapboxgl-ctrl-attrib-inner,
.app--location .map-wrapper .map-attrib-text {
  max-width: 100%;
  white-space: nowrap;
  overflow-x: auto;
}
.app--location .map-wrapper .leaflet-bottom.leaflet-right { max-width: 100%; }
.app--location .map-wrapper .map-attrib { max-width: 100%; box-sizing: border-box; }

@media (min-width: 1024px) {
  .app--location .controls-section { width: 58%; }
  .app--location .panel-head { height: 52px; }
  .app--location .panel-foot { height: 62px; padding-block: 8px; }
}
@media (max-width: 1023px) {
  .app--location .app-main { overflow: hidden; }
  /* The navigation has a real row, including on the shape, engraving and
     checkout screens. Only the fields scroll underneath the step heading. */
  .app:not(.app--location) > .app-main:has(> .controls-section > .panel-foot) {
    overflow: hidden;
  }
  .app:not(.app--location) .controls-section:has(> .panel-foot) {
    flex: 1 1 0%;
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
    box-sizing: border-box;
  }
  .app:not(.app--location) .controls-section > .panel-foot {
    position: static;
    height: auto;
    flex-shrink: 0;
  }
  .app:not(.app--location) > .app-main:has(> .controls-section > .panel-foot) > .viewer-section {
    min-height: 0;
    max-height: min(42dvh, max(76px, 100dvh - 250px));
  }
}
@media (max-width: 1023px) and (max-height: 600px) {
  .app--location .viewer-loading { flex-direction: row; gap: 8px; padding: 0 8px 44px; }
}
@media (max-width: 1023px) and (max-height: 540px) and (min-aspect-ratio: 3/2) {
  .app:not(.app--location) > .app-main:has(> .controls-section > .panel-foot) { flex-direction: row; }
  .app:not(.app--location) > .app-main:has(> .controls-section > .panel-foot) > .viewer-section {
    position: relative;
    flex: 1;
    height: auto;
    max-height: none;
  }
  .app:not(.app--location) .controls-section:has(> .panel-foot) { flex: 0 0 60%; width: 60%; }
}

/* Wildring's Location sheet opens at half the viewport. The search occupies
   the first 60px. Navigation sits below it, outside that half. */
@media (max-width: 1023px), (orientation: portrait) and (any-pointer: coarse) {
  .app--location {
    --location-sheet: 50vh;
    --location-search: 60px;
    --location-details: 31px;
    --location-nav: calc(48px + env(safe-area-inset-bottom, 0px));
  }
  @supports (height: 100dvh) {
    .app--location { --location-sheet: 50dvh; }
  }
  .app--location .app-header {
    position: absolute;
    inset: 0 0 auto;
    z-index: 12;
    height: 48px;
    padding-inline: 12px;
    border: 0;
    background: transparent;
    pointer-events: none;
  }
  .app--location .app-header :is(a, button, [role="button"]) { pointer-events: auto; }
  .app--location .header-brand-mark { width: 38px; height: 38px; }
  .app--location .app-main { flex-direction: column; min-height: 0; overflow: hidden; }
  .app--location .viewer-section {
    position: relative;
    flex: 1 1 0%;
    height: auto;
    min-height: 0;
  }
  .app--location .controls-section {
    display: grid;
    grid-template: "body body" minmax(0, 1fr) "title nav" var(--location-nav)
      / auto minmax(0, 1fr);
    flex: 0 0 calc(var(--location-sheet) + var(--location-details) + var(--location-nav));
    width: 100%;
    min-height: 0;
    box-sizing: border-box;
    border: 0;
    padding: 0;
  }
  .app--location .panel-body { grid-area: body; min-width: 0; }
  .app--location .map-selector {
    grid-template:
      "search search" minmax(var(--location-search), auto)
      "status status" auto
      "map map" minmax(max(100px, calc(var(--location-sheet) - var(--location-search))), 1fr)
      "warning warning" auto
      "rotate place" minmax(var(--location-details), auto)
      / minmax(0, 3fr) minmax(0, 2fr);
  }
  .app--location .map-selector > .search-row { padding: 8px 10px; }
  .app--location .search-row > :is(.search-input, .search-btn) { min-height: 44px; }
  .app--location .search-row > .search-btn { min-width: 44px; }
  .app--location .map-selector > .search-status { padding-inline: 10px; border-radius: 0; }
  .app--location .map-selector > .rot-row { min-width: 0; gap: 5px; padding: 0 8px; }
  .app--location .map-selector > .map-footer {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0 8px;
  }
  .app--location .map-footer .map-place-row {
    display: grid;
    align-content: center;
    min-width: 0;
    gap: 0;
    line-height: 1.1;
  }
  .app--location .map-footer .map-place { min-width: 0; }
  .app--location .map-footer .map-hint,
  .app--location .map-selector > .map-wrapper::after { display: none; }
  .app--location .map-wrapper > .map-switches { bottom: 8px; }
  .app--location .panel-head {
    grid-area: title;
    height: auto;
    gap: 0;
    padding: 0 8px env(safe-area-inset-bottom, 0px) 0;
    border: 0;
    border-top: 1px solid rgba(255,255,255,.07);
  }
  .app--location .panel-title-name { font-size: 17px; line-height: 1.15; }
  .app--location .panel-title-count { font-size: 12px; line-height: 1; }
  /* The Next button in the same row handles the forward action. */
  .app--location .panel-head .panel-arrow:last-child { display: none; }
  .app--location .panel-foot {
    grid-area: nav;
    position: static;
    height: auto;
    padding: 0 8px env(safe-area-inset-bottom, 0px) 4px;
    gap: 8px;
  }
  .app--location .step-track-names { display: none; }
  .app--location .panel-foot .step-next-btn { min-height: 44px; padding: 6px 16px; }
}
@media (orientation: landscape) and (max-width: 1023px) and (max-height: 540px) {
  /* The shallow map has room for a horizontal zoom/compass row. */
  .app--location .map-wrapper > .preset-row {
    right: calc(3 * var(--map-zoom-size) + 2 * var(--map-rail-gap));
  }
  .app--location .mapboxgl-ctrl-top-right .mapboxgl-ctrl-group,
  .app--location .leaflet-control-zoom { display: flex; }
  .app--location .map-wrapper > .map-switches {
    display: flex;
    width: auto;
    max-width: calc(100% - 140px);
  }
}
@media (max-width: 480px) {
  .app--location .map-footer .map-coords { font-size: 9px; letter-spacing: 0; }
}
@media (min-width: 1024px) and (orientation: landscape) and (any-pointer: coarse) {
  .app--location .app-header { height: 70px; }
  .app--location .controls-section { width: 50%; border-left: 0; }
  .app--location .controls-section > .panel-body { padding-inline: 16px; }
}
