/* Keep the street visible. Scene, sound and secondary actions occupy the top
   layer only while their native popover is open. */
:root {
  --street-hud-paper: #f9efd9;
  --street-hud-ink: #322a23;
  --street-hud-line: #9c8e78;
  --street-hud-jade: #21675f;
}

.hud-top-right:has(.street-hud-toolbar) { pointer-events: none; }
.hud-top-right > .street-hud-toolbar {
  anchor-name: --street-toolbar;
  width: max-content;
  max-width: 100%;
  height: auto;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
  padding: 4px;
  box-sizing: border-box;
  pointer-events: auto;
}

.street-hud-toolbar > .toolbar-divider { display: none; }
.street-hud-toolbar > .tool-btn { white-space: nowrap; }
body.hud-minimized .street-hud-toolbar > :not(#btn-toggle-hud) { display: none; }
body.hud-minimized .hud:not(.hud-top-right) { visibility: hidden; }

.street-hud-popover {
  position: fixed;
  inset: calc(max(16px, env(safe-area-inset-top)) + 57px) max(10px, env(safe-area-inset-right)) auto auto;
  width: min(340px, calc(100vw - 20px));
  max-height: min(480px, calc(100dvh - 96px));
  margin: 0;
  padding: 12px;
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--street-hud-ink);
  background: var(--street-hud-paper);
  border: 1px solid var(--street-hud-line);
  border-radius: 12px;
  box-shadow: 0 8px 24px #14141142;
  font: 600 13px/1.35 system-ui, sans-serif;
  accent-color: var(--street-hud-jade);
  pointer-events: auto;
  z-index: 1;
}

.street-hud-popover:popover-open { display: grid; gap: 8px; }
body.hud-minimized .street-hud-popover:popover-open { visibility: hidden; }

.street-hud-section-title { margin: 1px 0 0; font-size: 12px; }
.street-hud-popover .time-switch { display: flex; flex-wrap: wrap; gap: 4px; }
.street-hud-popover .time-btn,
.street-hud-popover .tool-btn,
.street-hud-popover .repo-link,
.street-music select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
  padding: 4px 8px;
  box-sizing: border-box;
  color: var(--street-hud-ink);
  background: #e9dec6;
  border: 1px solid #b0a58d;
  border-radius: 7px;
  font: inherit;
}

.street-hud-popover .time-btn.active,
.street-hud-popover .tool-btn[aria-pressed='true'] {
  background: var(--street-hud-jade);
  border-color: var(--street-hud-jade);
  color: #fff8ea;
}
.street-hud-popover :is(.time-btn, .tool-btn, .repo-link):hover:not(:disabled) { text-decoration: underline; }
.street-hud-popover .time-btn .seg-label { display: inline; max-width: none; opacity: 1; }
.street-hud-popover :is(button, select, input, a):focus-visible { outline: 2px solid var(--street-hud-jade); outline-offset: 2px; }
.street-hud-popover :disabled { opacity: .5; cursor: default; }
.street-hud-popover [hidden] { display: none !important; }
.street-hud-more { width: min(210px, calc(100vw - 20px)); }
.street-music { width: min(320px, calc(100vw - 20px)); }
.street-music select { display: block; width: 100%; }
.street-music-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.street-music-volume { display: grid; gap: 4px; }
.street-music-volume input { margin: 0; width: 100%; }
#slop-music-status { margin: 0; }
#slop-music-status:empty { display: none; }
.street-ink-adjustments { display: grid; gap: 5px; min-inline-size: 0; border: 1px solid #b0a58d; border-radius: 8px; }
.street-range { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; }
.street-range output { font-variant-numeric: tabular-nums; }
.street-range input { grid-column: 1 / -1; width: 100%; margin: 0; }

.street-orbit-hint {
  width: fit-content;
  margin: 0 auto 5px;
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--street-hud-paper);
  background: #251f1be8;
  font: 650 11px/1.45 system-ui, sans-serif;
  pointer-events: none;
  white-space: nowrap;
}
.street-orbit-hint kbd { border-color: #948573; }
.street-orbit-hint kbd + span::before { content: ': '; }
.street-orbit-hint--narrow { display: none; }

.street-location { display: grid; gap: 2px; width: min(196px, 100%); }
.street-nearest {
  margin: 0;
  padding: 4px 7px;
  border-radius: 5px;
  color: var(--street-hud-paper);
  background: #251f1be8;
  overflow-wrap: anywhere;
  font: 600 11px/1.25 system-ui, sans-serif;
}
.street-nearest[hidden] { display: none; }

body:has(.street-hud-toolbar--shared) .hud-bottom-left { width: min(196px, 30vw); gap: 5px; }
body:has(.street-hud-toolbar--shared) .radar { width: 100%; height: clamp(68px, 12vw, 123px); border-radius: 12px; }
body:has(.street-hud-toolbar--shared) .hud-bottom-right { width: min(168px, 38vw); }
body:has(.street-hud-toolbar--shared) .gauge-speed { font-size: clamp(24px, 3.5vw, 34px); }
body:has(.street-hud-toolbar--shared) .cluster { padding: 7px 9px; }
body:has(.street-hud-toolbar--shared) .camera-current { overflow-wrap: anywhere; font-size: 11px; }
body:has(.street-hud-toolbar--shared) .camera-switch .icon-btn { min-width: 26px; width: auto; padding-inline: 5px; }
body:has(.street-hud-toolbar--shared) .hud-bottom-center { anchor-name: --street-travel-dock; }
body.touch-enabled .mode-btn.mode-fit:not([hidden]) { width: auto; min-width: 44px; padding-inline: 8px; }

button.radar { padding: 0; text-align: left; }

@media (max-width: 1240px) {
  .street-orbit-hint--narrow { display: block; }
}

@media (max-width: 820px) {
  .hud-top-right:has(.street-hud-toolbar) { max-width: calc(100vw - 16px); }
  .street-hud-popover { inset-block-start: calc(max(8px, env(safe-area-inset-top)) + 56px); }
  .street-hud-toolbar > .tool-btn { padding-inline: 6px !important; font-size: 12px; }
  .street-hud-popover :is(.time-btn, .tool-btn, .repo-link, select, input[type='range']) { min-height: 44px; }
}

@supports (top: anchor(--street-toolbar bottom)) {
  .street-hud-popover { inset-block-start: calc(anchor(--street-toolbar bottom) + 7px); }
}

@media (max-width: 620px) {
  .hud-top-right:has(.street-hud-toolbar) { z-index: 11; }
  .hud-top-right:has(.street-hud-toolbar--shared) {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
  }
  .street-hud-toolbar--shared > .tool-btn,
  .street-hud-popover :is(.time-btn, .tool-btn),
  body:has(.street-hud-toolbar--shared) .mode-btn { min-height: 44px; min-width: 44px; }
  .street-hud-toolbar--shared > .tool-btn kbd { display: none; }
  .street-hud-toolbar--shared:lang(zh) .street-long-label { display: none; }
  .street-hud-toolbar--shared:lang(zh) #btn-street-scene::after { content: '场景'; }
  .street-hud-toolbar--shared:lang(zh-Hant) #btn-street-scene::after { content: '場景'; }
  .street-hud-toolbar--shared:lang(zh) #btn-street-music::after { content: '音乐'; }
  .street-hud-toolbar--shared:lang(zh-Hant) #btn-street-music::after { content: '音樂'; }
  .street-hud-toolbar--shared:lang(zh) #btn-street-more::after { content: '更多'; }
  body:has(.street-hud-toolbar--shared) .hud-bottom-left {
    top: var(--street-radar-top, calc(max(8px, env(safe-area-inset-top)) + 106px));
    bottom: auto;
    left: max(8px, env(safe-area-inset-left));
  }
  body:has(.street-hud-toolbar--shared) .hud-bottom-right {
    top: var(--street-radar-top, calc(max(8px, env(safe-area-inset-top)) + 106px));
    bottom: auto;
    right: max(8px, env(safe-area-inset-right));
    width: min(160px, 45vw);
  }
  @supports (top: anchor(--street-toolbar bottom)) {
    body:has(.street-hud-toolbar--shared) :is(.hud-bottom-left, .hud-bottom-right) {
      top: calc(anchor(--street-toolbar bottom) + 9px);
    }
  }
}

@media (pointer: coarse) {
  .street-orbit-hint { display: none; }
  body:has(.street-hud-toolbar--shared) .camera-switch { display: flex; gap: 2px; }
  body:has(.street-hud-toolbar--shared) .camera-switch .icon-btn { min-width: 44px; min-height: 44px; }
}

@media (max-width: 620px) and (min-height: 501px) {
  @supports (bottom: anchor(--street-travel-dock top)) {
    body.touch-enabled:has(.street-hud-toolbar--shared) #touch-controls { bottom: calc(anchor(--street-travel-dock top) + 6px); }
  }
}
