/* ---- 3.6 pixel scale ------------------------------------------------------ */
/* --px is the app-wide integer UI scale (pixel-scale.js sets it by width);
   sheet-fed elements size as calc(N * var(--px)) and never resample. */

:root {
  --px: 2px;
}

.px-text {
  display: none;
  vertical-align: middle;
  image-rendering: pixelated;
}

.font-ready .px-text {
  display: inline-block;
}

/* the DOM text stays for screen readers and tests once the bitmap shows */
.font-ready .px-src {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- 5.2 overlays and the city minimap; the side panels (5.7) ---------- */

.side-panels {
  position: fixed;
  right: 8px;
  top: calc(var(--strip-h, 56px) + 8px);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-height: calc(100vh - var(--strip-h, 56px) - 16px);
  overflow-y: auto;
  pointer-events: none;
}

.side-panels > * {
  pointer-events: auto;
}

/* the sheet's panel: lavender, dark edge, light inner rim, navy ink */
.side-panel,
.overlay-menu,
.query-panel,
.feed-panel,
.graph-panel,
.budget-controls,
.msg-toast {
  padding: calc(2 * var(--px)) calc(3 * var(--px));
  color: var(--sheet-ink);
  background: var(--sheet-panel);
  border: var(--px) solid var(--sheet-edge);
  box-shadow: inset var(--px) var(--px) 0 var(--sheet-hi), inset calc(-1 * var(--px)) calc(-1 * var(--px)) 0 var(--sheet-lo);
  font-size: 0.75rem;
  line-height: 1.4;
}

.hud-hint {
  margin: 0;
  max-width: 22rem;
  white-space: normal;
}

.overlay-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--px);
  max-width: 22rem;
}

.overlay-menu button {
  font-size: 0.7rem;
}

/* 12.2 the map window (simcity_ui_minimap.png, _heat.png): a framed box
   centred over the city, a title bar naming the overlay, the square map,
   a MAX…MIN scale on the right for heat overlays, the overlay icons along
   the bottom. Runs at --hud-px like the band. */
.map-window {
  --px: var(--hud-px, 2px);
  --ipx: var(--hud-px, 2px);
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: calc(3 * var(--px));
  max-width: calc(100vw - 12px);
  padding: calc(3 * var(--px));
  background: #b0b0d8;
  border: var(--px) solid #383868;
  box-shadow: inset 0 0 0 var(--px) #e8e8f8, inset 0 0 0 calc(2 * var(--px)) #8080b8, 0 calc(2 * var(--px)) 0 rgba(0, 0, 0, 0.45);
}

.map-window[hidden] {
  display: none;
}

.map-title-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(4 * var(--px));
  padding: var(--px) calc(4 * var(--px));
  color: #f8f8f8;
  background: #6868a8;
  border: var(--px) solid #383868;
}

.map-title-bar .px-text {
  filter: drop-shadow(var(--px) var(--px) 0 #181840);
}

.map-title-bar button {
  margin-left: auto;
}

.map-body {
  display: flex;
  align-items: stretch;
  gap: calc(3 * var(--px));
}

.city-minimap {
  width: min(calc(120 * var(--px)), 62vw, 52vh);
  image-rendering: pixelated;
  border: var(--px) solid #383868;
  background: #183078;
}

.map-scale {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--px);
  padding: calc(2 * var(--px));
  color: #f8f8f8;
  background: #283060;
  border: var(--px) solid #383868;
}

.map-scale[hidden] {
  display: none;
}

.map-ramp {
  flex: 1;
  width: calc(6 * var(--px));
  border: var(--px) solid #101030;
}

.map-icons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--px);
}

.map-icons button:not(.icon-btn) {
  min-width: calc(16 * var(--ipx));
  height: calc(16 * var(--ipx));
  padding: 0 var(--px);
  font-size: max(9px, calc(5 * var(--px)));
  background: #adaad6;
}

.icons-ready .map-icons .icon-btn[aria-pressed="true"],
.map-icons button[aria-pressed="true"] {
  outline: var(--px) solid #f8d070;
  outline-offset: 0;
}

/* ---- Budget window (5.3): the 256×240 Budget Screen sheet at --px, the
   controls under it. --------------------------------------------------- */
.budget-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 96vw;
  max-height: 96vh;
  overflow: auto;
}

.budget-panel[hidden] {
  display: none;
}

.budget-sheet {
  width: calc(256 * var(--px));
  height: calc(240 * var(--px));
  max-width: 94vw;
  max-height: 80vh;
  aspect-ratio: 256 / 240;
  object-fit: contain;
  image-rendering: pixelated;
  cursor: var(--hand, pointer);
}

.budget-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 10px;
  max-width: calc(256 * var(--px));
  padding: 4px 8px;
  font-size: 0.75rem;
}

.budget-controls input[type="range"] {
  width: 6rem;
  vertical-align: middle;
}

/* ---- Query (5.4), messages (5.5), graphs (5.6): sheet panels (5.7) ---- */
.query-panel {
  max-width: 16rem;
}

.query-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.query-title {
  font-weight: bold;
}

.query-head button {
  padding: 0 calc(2 * var(--px));
}

.query-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 8px;
  margin: 4px 0 0;
}

.query-rows dt {
  color: var(--sheet-lo);
}

.query-rows dd {
  margin: 0;
}

.msg-toast {
  position: fixed;
  left: 50%;
  bottom: 3.5rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(36rem, 92vw);
  /* the cartridge's message box (operator): white paper, a thick black
     border, bold black text, big enough to read from the couch; it zooms
     with the menu scale like the band */
  padding: 0.6rem 1.1rem;
  background: #fff;
  color: #000;
  border: 6px solid #000;
  box-shadow: none;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  zoom: var(--menu-scale, 1);
  z-index: 20;
  pointer-events: none;
}

.msg-toast.urgent {
  color: #c02020;
}

.msg-pic {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  flex: none;
}

.msg-text {
  margin: 0;
}

.feed-panel {
  max-width: 22rem;
}

.feed-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  max-height: 12rem;
  overflow-y: auto;
}

.feed-list li.urgent {
  color: #c02020;
}

@media (max-width: 899px) {
  .msg-toast {
    bottom: calc(var(--board-h, 80px) + 3rem);
  }
}

/* ---- Graphs (5.6): the census histories on a native-pixel canvas. ------ */
.graph-panel {
  max-width: calc(132 * var(--px));
}

.graph-range button[aria-pressed="true"],
.graph-legend button[aria-pressed="true"] {
  outline: 1px solid var(--sheet-ink);
}

.graph-legend button[aria-pressed="false"] {
  opacity: 0.45;
}

.graph-canvas {
  display: block;
  margin-top: 4px;
  width: calc(120 * var(--px));
  height: calc(64 * var(--px));
  max-width: 90vw;
  image-rendering: pixelated;
}

/* 12.19: the year labels, two canvas px per graph column, under the plot */
.graph-years {
  display: block;
  margin-top: 1px;
  width: calc(120 * var(--px));
  height: calc(7.5 * var(--px));
  max-width: 90vw;
  image-rendering: pixelated;
  color: var(--sheet-ink);
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  margin-top: 4px;
}

.graph-legend button {
  font-size: 0.7rem;
  padding: 0 3px;
}

.graph-swatch {
  display: inline-block;
  width: calc(4 * var(--px));
  height: calc(4 * var(--px));
  margin-right: 3px;
  vertical-align: middle;
}

.graph-axis {
  margin: 2px 0 0;
  color: var(--sheet-lo);
}
