/* Geospatial Playground layout: map in its own stage, controls in a side
   column (desktop) or a scrollable stack below the map (mobile). Loaded last.
   Does not change URLs or folder names. */
html, body {
  overflow: hidden;
}
.geo-app {
  height: 100%;
  max-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--paper, #e7decb);
}
.geo-head {
  grid-column: 1 / -1;
  grid-row: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 56px;
  box-sizing: border-box;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px 210px;
  background: var(--paper, #e7decb);
  border-bottom: 1px solid var(--paper-rule, rgba(28, 25, 20, 0.16));
  z-index: 4;
}
.geo-head .brand {
  position: static;
  max-width: none;
  width: auto;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  gap: 2px;
}
.geo-head .brand h1 {
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}
.geo-head .brand p {
  display: block;
  font-size: 11px;
}
.geo-stage {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--paper, #e7decb);
  overflow: hidden;
}
.geo-stage canvas#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* HUD toggle sits in the header so it never covers the map. */
.geo-head {
  justify-content: space-between;
  gap: 12px;
}
.geo-head .brand { flex: 1 1 auto; min-width: 0; }
.geo-head .hud-toggle-pill,
.hud-toggle-pill {
  position: static;
  transform: none;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  flex-shrink: 0;
  z-index: 6;
  min-height: 44px;
  min-width: 44px;
  margin: 0;
}

/* Controls column / stack: flow, not overlay. */
#hud.geo-controls,
.geo-controls.hud {
  position: relative;
  inset: auto;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: auto;
  max-width: none;
  max-height: none;
  height: auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 20px;
  background: var(--paper, #e7decb);
  border-left: 1px solid var(--paper-rule, rgba(28, 25, 20, 0.16));
  pointer-events: auto;
  opacity: 1;
  z-index: 5;
  -webkit-overflow-scrolling: touch;
}
#hud.geo-controls.hidden,
body.geo-hud-off #hud.geo-controls {
  display: none;
  opacity: 1;
  pointer-events: none;
}
body.geo-hud-off .geo-app {
  grid-template-columns: minmax(0, 1fr);
}

/* Neutralize the old fixed/floating panel positioning. */
.geo-controls .topbar,
.geo-controls .side-stack,
.geo-controls .route-panel,
.geo-controls .telemetry,
.geo-controls .proj-bar,
.geo-controls .brand {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  inset: auto;
  width: auto;
  max-width: none;
  max-height: none;
  z-index: auto;
  pointer-events: auto;
}
.geo-controls .side-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: visible;
}
.geo-controls .topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.geo-controls .proj-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  justify-content: stretch;
  max-width: none;
  padding: 4px;
  flex-wrap: unset;
}
.geo-controls .proj-btn {
  width: 100%;
  justify-content: flex-start;
}
.geo-controls .proj-btn,
.geo-controls .tog,
.geo-controls .preset-btn,
.geo-controls .seg button,
.geo-controls .hud-toggle-pill {
  min-height: 44px;
}
.geo-controls .route-panel,
.geo-controls .telemetry,
.geo-controls .card,
.geo-controls .proj-bar {
  box-shadow: none;
}
.geo-controls .route-panel .dn {
  display: flex;
  justify-content: flex-start;
  margin: 10px 0 0;
}
.geo-controls .telemetry {
  display: block;
}

/* Desktop compact-height overrides from the original page used 36px hits
   and hid descriptions. Keep 44 px targets; allow the column to scroll. */
@media (min-width: 900px) {
  body.plate-geo .topbar { top: auto; }
  .geo-controls .proj-btn { min-height: 44px; }
  .geo-controls .side-stack { top: auto; bottom: auto; width: auto; }
  .geo-controls .crs-desc { display: block; }
}

@media (max-width: 899px) {
  .geo-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(200px, 44vh) minmax(0, 1fr);
  }
  .geo-head {
    grid-row: 1;
    display: block;
    padding: calc(max(8px, env(safe-area-inset-top)) + 52px) 12px 8px 12px;
    min-height: 0;
    align-items: flex-start;
  }
  .geo-head .hud-toggle-pill {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    left: auto;
    bottom: auto;
    transform: none;
  }
  .geo-head .brand p { display: none; }
  .geo-head .brand h1 { font-size: 1.28rem; }
  .geo-stage { grid-column: 1; grid-row: 2; }
  #hud.geo-controls,
  .geo-controls.hud {
    grid-column: 1;
    grid-row: 3;
    border-left: none;
    border-top: 1px solid var(--paper-rule, rgba(28, 25, 20, 0.16));
    padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  }
  body.geo-hud-off .geo-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  body.geo-hud-off .geo-stage { grid-row: 2; }
  .geo-controls .side-stack { display: flex; }
  .geo-controls .telemetry { display: block; }
  .geo-controls .proj-bar { overflow: visible; }
}

@media (max-width: 360px) {
  .geo-head .brand h1 { font-size: 1.18rem; }
  .geo-controls .preset-btn { font-size: 9px; letter-spacing: 0.02em; padding: 0 6px; }
  .geo-stage { min-height: 180px; }
}

@media (max-width: 899px) and (max-height: 500px) {
  .geo-app { grid-template-rows: auto minmax(160px, 40vh) minmax(0, 1fr); }
}

/* Home / plate titles: let the longer names wrap cleanly, don't clip the sweep. */
.plates article h2.ptitle,
.plates article h2 {
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}
body.plate-dtg .card h1,
body.plate-dtg .card h1.ptitle {
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

/* On the narrowest phones the full "H · HIDE HUD" label collides with the back button. */
@media (max-width: 360px) {
  .geo-head .hud-toggle-pill .hud-pill-rest { display: none; }
  .geo-head .hud-toggle-pill {
    width: 44px;
    min-width: 44px;
    padding: 0;
    letter-spacing: 0;
  }
}
