/* 12.7 RCI (simcity_ui_basic.jpg): a dark pill with a red rim holds the
   letters R C I in their colours; each letter's bar grows up from the pill
   for demand and down from it for surplus, nothing at zero. play.js sets the
   bar's height in whole native pixels (rciBars, ±RCI_HALF_PX).
   12.9: the pill is wide and sits level with the population row (the band's
   lower half), the letters in the bitmap font; the bars reach 16 px, the
   height of one number row, up into the date row and down to the band's
   foot. Height 16 + 17 + 16.
   Operator (2026-10-11): the letters are a bit less high (0.8 of the font's
   cell, cap height 11 rows) with room above and below them in a pill two
   rows taller (19), a white rim and a dark grey inner ring. Height
   16 + 19 + 16. The letters' own --px is the smaller one; --rci-px is the
   pill's. */
.rci {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, calc(9 * var(--px)));
  column-gap: var(--px);
  height: calc(51 * var(--px));
  padding: 0 calc(6 * var(--px));
  --rci-px: var(--px);
}

.rci::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(16 * var(--px));
  height: calc(19 * var(--px));
  box-sizing: border-box;
  border: var(--px) solid #f8f8f8;
  box-shadow: inset 0 0 0 var(--px) #484850;
  border-radius: calc(8 * var(--px));
  background: #101018;
}

.rci-bar {
  position: relative;
  height: 100%;
}

.rci-fill {
  position: absolute;
  left: calc(2 * var(--px));
  right: calc(2 * var(--px));
  bottom: calc(35 * var(--px));
  height: 0;
}

.rci-fill.neg {
  bottom: auto;
  top: calc(35 * var(--px));
}

.rci-bar[data-zone="r"] { --rci: #f03828; }
.rci-bar[data-zone="c"] { --rci: #3878f8; }
.rci-bar[data-zone="i"] { --rci: #f8d038; }
.rci-fill { background: var(--rci); }

.rci-label {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(16 * var(--rci-px));
  height: calc(19 * var(--rci-px));
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  /* the bitmap canvas sizes itself in --px: 0.8 of the pill's unit */
  --px: calc(0.8 * var(--rci-px));
  font-size: calc(9 * var(--px));
  font-weight: bold;
  line-height: calc(15 * var(--px));
  color: var(--rci);
}

/* the cell's two descender rows sit below the caps: lift the canvas by one
   row so the cap height (rows 0-13) is what centres in the pill */
.rci-label .px-text {
  margin-top: calc(-1 * var(--px));
}

/* Buttons: plain sheet-coloured ones until the icons load, then the cells. */
.play-page button,
.title-btn {
  font: inherit;
  font-size: max(10px, calc(5 * var(--px)));
  color: var(--sheet-ink);
  background: var(--sheet-hi);
  border: var(--px) solid var(--sheet-edge);
  padding: var(--px) calc(2 * var(--px));
  cursor: var(--hand, pointer);
  text-decoration: none;
}

/* the strip's and the board's text fallbacks shrink with them (5.12) */
.play-page .play-hud button,
.play-page .palette button {
  font-size: max(5px, calc(5 * var(--px)));
}

.play-page button[aria-pressed="true"] {
  background: var(--sheet-on);
}

.play-page button:focus-visible,
.title-btn:focus-visible {
  outline: var(--px) solid var(--accent);
  outline-offset: var(--px);
}

.icons-ready .icon-btn {
  display: inline-block;
  position: relative;
  flex: none;
  width: calc(var(--iw) * var(--ipx));
  height: calc(var(--ih) * var(--ipx));
  padding: 0;
  border: 0;
  background: var(--icon) 0 0 / 100% 100% no-repeat;
  image-rendering: pixelated;
}

/* the full shorthand: .play-page button[aria-pressed] would reset size and repeat */
.icons-ready .icon-btn[aria-pressed="true"] {
  background: var(--icon-on) 0 0 / 100% 100% no-repeat;
}

.icons-ready .icon-btn[aria-expanded="true"] {
  outline: var(--px) solid var(--sheet-on);
  outline-offset: 0;
}

.icons-ready .icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.hint-btn {
  width: calc(16 * var(--ipx));
  height: calc(16 * var(--ipx));
  padding: 0;
  font-weight: bold;
}

.hud-overlay {
  min-width: 0;
}

/* 12.1 the tool palette: two columns of large icons on a light panel down
   the left edge under the band, the hovered tool's name under it. 12.7: one
   translucent black column behind it from under the band down to the tool's
   price, no further (operator); only the board and the lines take clicks. */
.palette {
  position: fixed;
  left: calc(6px + var(--crt-inset, 0px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: max-content;
  /* the band sits 6px down at the menu scale and --strip-h is its scaled
     height, so only the height is divided back; the board tucks 3 hud px
     under the band at every scale */
  top: calc(6px + var(--crt-inset, 0px) + var(--strip-h, 28px) / var(--menu-scale, 1) - 3 * var(--hud-px, 2px));
  z-index: 10;
  padding: 3px 4px 4px;
  background: rgba(0, 0, 0, 0.55);
  background-clip: padding-box;
  /* 12.16: a 10 px rim right (lighter: white .18 over black .8) and at the
     foot (darker), none on top or left */
  border: 0 solid transparent;
  border-right: 10px solid rgb(46 46 46 / 0.84);
  border-bottom: 10px solid rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.palette > * {
  pointer-events: auto;
}

.tool-board {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: var(--px);
  padding: calc(2 * var(--px));
  background: #c8c8e8;
  border: var(--px) solid #484878;
  box-shadow: inset var(--px) var(--px) 0 #f0f0f8, inset calc(-1 * var(--px)) calc(-1 * var(--px)) 0 #8888b8;
}

/* the name and the price: never wider than the board (width 0, stretched);
   play.js fitText picks the integer scale, the price never above the name */
.tool-name,
.tool-price {
  --px: var(--hud-px, 2px);
  width: 0;
  min-width: 100%;
  overflow: hidden;
  color: #f8f8f8;
  white-space: nowrap;
  filter: drop-shadow(var(--px) 0 0 #000) drop-shadow(0 var(--px) 0 #000);
}

.tool-board .tool {
  position: relative;
}

.tool:not(.icon-btn) {
  min-width: 2.25rem;
}

.key-tag {
  font: inherit;
  margin-right: 0.3em;
}

/* the key as a bitmap tag in the icon's corner, one CSS px per glyph px;
   12.7: only while the pointer is on the tool or focus is, never on touch */
.palette .tool:not(:hover):not(:focus-visible) .key-tag {
  opacity: 0;
}

.key-pic {
  visibility: hidden;
}

.tool:hover .key-pic,
.tool:focus-visible .key-pic {
  visibility: visible;
}

@media (hover: none) {
  .tool:hover .key-pic {
    visibility: hidden;
  }
}

.key-pic {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 1px;
  background: var(--sheet-hi);
  image-rendering: pixelated;
  pointer-events: none;
}

.hud-tool,
.hud-cost {
  font-size: 0.75rem;
  color: #f8f8f8;
}

@media (max-width: 899px) {
  .hud.play-hud {
    top: 0;
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    column-gap: calc(4 * var(--px));
  }
  .palette {
    top: auto;
    right: auto;
    left: 50%;
    bottom: 6px;
    transform: translateX(-50%);
    align-items: center;
    width: auto;
    max-width: calc(100vw - 12px);
    padding: 4px;
  }
  .palette .tool-name,
  .palette .tool-price {
    display: none;
  }
  .tool-board {
    grid-template-columns: repeat(8, auto);
  }
}

/* on phones the map number and overlay name stay for screen readers only */
@media (max-width: 899px) {
  .play-hud .map-row,
  .play-hud .hud-overlay {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

/* 12.6 menu scale: one variable zooms the band, the palette and the windows */
.play-page .play-hud,
.play-page .palette,
.map-window,
.msg-window {
  zoom: var(--menu-scale, 1);
}

.settings-body {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: calc(2 * var(--px)) calc(6 * var(--px));
  padding: calc(2 * var(--px)) calc(4 * var(--px));
  color: #181840;
  font-size: max(11px, calc(6 * var(--px)));
}

.settings-window #settings-reset,
.settings-window #settings-debug {
  align-self: center;
}

/* SETTINGS > DEBUG: the Goodbye screen's debug rows, label left, value right */
.debug-rows {
  display: grid;
  gap: calc(1 * var(--px));
  padding: calc(2 * var(--px)) calc(4 * var(--px));
  min-width: calc(110 * var(--px));
}

.debug-rows button {
  display: flex;
  justify-content: space-between;
  gap: calc(8 * var(--px));
  color: #181840;
  font-size: max(11px, calc(6 * var(--px)));
}

.debug-rows button.current,
.debug-rows button[aria-current="true"] {
  outline: 2px solid #181840;
}

/* 12.3: the last message line is for screen readers only; Dr. Wright
   speaks in windows (below) and toasts. */
.hud-msg,
.msg-window-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* 12.3 message windows (simcity_ui_disasters.png, _congratulations.jpg,
   _gift.webp): a lavender-bordered window over the city, its canvas holding
   the text and the scene at native pixels, scaled by --hud-px. */
.msg-window {
  --px: var(--hud-px, 2px);
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  padding: calc(4 * 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);
  cursor: var(--hand, pointer);
}

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

.msg-canvas {
  display: block;
  width: min(calc(256 * var(--px)), calc(100vw - 40px));
  image-rendering: pixelated;
  border: var(--px) solid #383868;
}
