/* Mobile-first shell overrides. The scene keeps the space between controls. */
html {
  -webkit-text-size-adjust: 100%;
}
#app {
  --edge: 12px;
  height: 100dvh;
}
#app button {
  touch-action: manipulation;
}
#app dialog button {
  min-width: 44px;
  min-height: 44px;
}
#app select,
#app input:not([type="range"]):not([type="checkbox"]) {
  font-size: 16px;
}
#app .topbar {
  gap: 4px;
  padding: max(10px, env(safe-area-inset-top))
    max(var(--edge), env(safe-area-inset-right)) 10px
    max(var(--edge), env(safe-area-inset-left));
}
#app .brand {
  min-width: 44px;
  min-height: 44px;
}
#app .brand > span:last-child,
#app .project-mark,
#app .cutaway-button span,
#app .topbar button span {
  display: none;
}
#app .header-actions {
  gap: 4px;
  min-width: 0;
}
#app .topbar button {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
}
#app .topbar .story-launch {
  width: auto;
  max-width: 100%;
  margin: 0 0 0 auto;
}
#app .tools-rail {
  top: calc(78px + env(safe-area-inset-top));
  right: var(--edge);
  gap: 6px;
}
#app .tools-rail button {
  width: 44px;
  height: 44px;
}
#app .view-card {
  display: none;
}
body:is(.city-view, .outside-view, .mayfield-view, .neighbourhood-view)
  #app
  .view-card {
  top: calc(122px + env(safe-area-inset-top));
  right: 70px;
  bottom: auto;
  left: max(var(--edge), env(safe-area-inset-left));
  display: block;
  width: auto;
  padding: 10px 12px;
}
#app .view-card h2 {
  font-size: 17px;
}
#app .view-card p,
#app .view-card-foot {
  display: none;
}
#app .bottom {
  right: max(var(--edge), env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(var(--edge), env(safe-area-inset-left));
}
.navigation-scroll-hint {
  margin: 0 0 5px;
  font-size: 10px;
  color: #cbd3cf;
}
#app .bottom-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  justify-content: flex-start;
  margin-bottom: 6px;
}
#app .bottom-top .mode-toggle {
  position: static;
  align-self: flex-end;
  margin: 0;
}
#app .view-tabs {
  gap: 16px;
  min-width: 0;
  padding: 0;
  margin: 0;
  overscroll-behavior-x: contain;
}
#app .view-tabs button {
  flex: 0 0 auto;
  min-height: 44px;
  font-size: 11px;
}
#app .mode-toggle button {
  min-height: 44px;
  padding: 8px 12px;
}
#app .platform-strip {
  gap: 8px;
  padding: 6px 0;
}
#app .platform-label {
  display: none;
}
#app #platform-buttons {
  gap: 5px;
  justify-content: flex-start;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
#app .cutaway-button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
}
#app footer {
  margin-top: 6px;
}
#app #navigation-hint,
#app .footnote {
  display: none;
}
#app .rail-controls {
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
#app .rail-controls button {
  min-height: 44px;
  font-size: 11px;
}
#app #bus-routes-open {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
#app #rail-status {
  flex-basis: 100%;
  overflow-wrap: anywhere;
}
#app .bottom > [id$="-views"]:not([hidden]) {
  display: flex;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
#app .bottom > [id$="-views"] > span {
  display: none;
}
#app .settings-panel button,
#app .sound-panel button,
#app .view-card-foot button {
  min-width: 44px;
  min-height: 44px;
}
#app .panel-title {
  gap: 12px;
}
#app .panel-title button {
  flex-shrink: 0;
}
#app .settings-panel .switch-row {
  gap: 12px;
  min-height: 44px;
  padding-right: 44px;
  margin-block: 4px;
}
#app .switch-row input {
  width: 44px;
  height: 44px;
  margin: 0;
}
#app .switch-row .switch {
  position: absolute;
  right: 7px;
}
#app :is(.settings-panel, .sound-panel) input[type="range"] {
  height: 44px;
  margin-block: 0;
}
#app :is(.settings-panel, .sound-panel) select {
  min-width: 0;
  min-height: 44px;
}
#app .sound-panel label:has(select) {
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  justify-content: flex-start;
}
#app .sound-panel label select {
  width: 100%;
  max-width: none;
}
#app .sound-cues {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#app .sound-panel .sound-cues select {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
}
#app .sound-voices-row {
  flex-wrap: wrap;
  gap: 8px;
}
#app dialog {
  max-height: calc(
    100dvh -
    24px -
    env(safe-area-inset-top) -
    env(safe-area-inset-bottom)
  );
  overscroll-behavior-y: contain;
}
#app dialog .dialog-close {
  top: 8px;
  right: 8px;
}
#app .bottom > [id$="-views"] button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px;
  font-size: 11px;
  white-space: nowrap;
}
#app .settings-panel,
#app .sound-panel {
  top: calc(70px + env(safe-area-inset-top));
  right: max(var(--edge), env(safe-area-inset-right));
  width: min(
    340px,
    calc(
      100% -
      max(var(--edge), env(safe-area-inset-left)) -
      max(var(--edge), env(safe-area-inset-right))
    )
  );
  max-height: calc(
    100dvh -
    90px -
    env(safe-area-inset-top) -
    env(safe-area-inset-bottom)
  );
  overflow-y: auto;
  overscroll-behavior-y: contain;
}
#app #platform-buttons button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: 0;
  font-size: 12px;
}

@media (min-width: 768px) {
  #app {
    --edge: 24px;
  }
  #app .brand > span:last-child,
  #app .topbar button span {
    display: initial;
  }
  #app .topbar {
    gap: 12px;
  }
  #app .topbar .story-launch {
    margin: 0;
  }
  #app .header-actions {
    gap: 12px;
  }
  #app .sound-panel label:has(select) {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  #app .sound-panel label select {
    width: auto;
    max-width: 172px;
  }
  #app .sound-cues {
    display: flex;
  }
  #app .sound-panel .sound-cues select {
    width: auto;
  }
  #app .bottom-top {
    flex-direction: row;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
  }
  #app .bottom-top .mode-toggle {
    flex-shrink: 0;
    align-self: auto;
  }
  #app .rail-controls {
    flex-wrap: nowrap;
  }
  #app #rail-status {
    flex-basis: auto;
  }
  #app .view-card,
  body:is(.city-view, .outside-view, .mayfield-view, .neighbourhood-view)
    #app
    .view-card {
    top: auto;
    right: calc(var(--edge) + 60px);
    bottom: 285px;
    left: auto;
    display: block;
    width: 226px;
    padding: 18px;
  }
  #app .view-card h2 {
    font-size: 22px;
  }
  #app .view-card p {
    display: block;
  }
  #app .view-card-foot {
    display: flex;
  }
}
@media (min-width: 1024px) {
  #app {
    --edge: 40px;
  }
  #app .topbar {
    padding-top: 24px;
    padding-bottom: 24px;
  }
  #app .tools-rail {
    top: 128px;
  }
  #app .platform-label {
    display: flex;
  }
  #app .cutaway-button span {
    display: initial;
  }
  #app .navigation-scroll-hint {
    font-size: 11px;
  }
}
@media (min-width: 1280px) {
  #app .project-mark {
    display: flex;
  }
}

/* Short phones and landscape views need room between the two control rails. */
@media (max-height: 650px) {
  #app .intro,
  #app .view-card,
  body:is(.city-view, .outside-view, .mayfield-view, .neighbourhood-view)
    #app
    .view-card {
    display: none;
  }
  #app .tools-rail {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
  #app .bottom {
    max-height: calc(
      100dvh -
      190px -
      env(safe-area-inset-top) -
      env(safe-area-inset-bottom)
    );
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
}

body.walking #app :is(.intro, .view-card) {
  display: none;
}

body.walking #app :is(.bottom, .tools-rail, .brand, .project-mark, .scrim),
body.walking #app :is(#story-open, #ride-nearest-bus, #sources-open) {
  display: none;
}

body.walking #app .header-actions {
  margin-left: auto;
}

body.walking #app #exit-walk {
  min-height: 44px;
  padding: 10px 14px;
}
