/* field.css — the field-guide chrome. Parchment, ink, one monospace, 1 px
   borders, uppercase letter-spaced headings, no glow, no big buttons, no
   animation in the chrome. The map canvas fills the window; a 300 px panel
   on the right; the build remote on the left; demand bars top-left. */

:root {
  --bg: #edeade;
  --panel: #f6f4ec;
  --border: #c8c2ae;
  --ink: #3b382e;
  --dim: #8a8474;
  --accent: #6f8c5c;
  --bad: #a4453c;
  --warn: #8a6a2e;
  --map: #d6d1bf;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- strip ---- */
#strip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex: none;
  flex-wrap: nowrap;
  white-space: nowrap;
}
h1 { font-size: 13px; margin: 0 6px 0 0; letter-spacing: 3px; font-weight: 600; flex: none; }
h2 { font-size: 11px; margin: 10px 0 6px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); }
h3 { font-size: 11px; margin: 8px 0 4px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); }
#tools { display: flex; align-items: center; gap: 2px; flex: none; }
#tools .sep { color: var(--dim); padding: 0 3px; }
button {
  font: inherit; color: var(--ink);
  background: #fffdf6; border: 1px solid var(--border); padding: 1px 6px;
  cursor: pointer; line-height: 1.4;
}
button:hover { border-color: var(--accent); }
button:disabled { color: var(--dim); cursor: default; border-color: var(--border); }
button.primary { background: var(--accent); color: #fffdf6; border-color: var(--accent); letter-spacing: 1px; }
button.tool .key { color: var(--dim); }
button.tool.on { background: var(--ink); color: #fffdf6; border-color: var(--ink); }
button.tool.on .key { color: #c8c2ae; }
#cost { margin-left: 3px; min-width: 0; flex: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
#cost.refused { color: var(--bad); }
#clock { margin-left: auto; flex: none; color: var(--dim); }

/* The Use brush is a union of checkboxes: no boxes means mixed; every checked
   group/species is admitted. It is a non-modal field palette so the map stays
   paintable while the choices remain visible. */
#usePicker {
  position: fixed; z-index: 9; top: 34px; left: 150px;
  width: min(390px, calc(100vw - 16px)); max-height: calc(100vh - 42px); overflow: auto;
  padding: 8px 10px; background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 3px 12px rgba(59, 56, 46, 0.22);
}
#usePicker .use-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
#usePicker .use-head b { flex: 1; letter-spacing: 1px; text-transform: uppercase; }
#usePicker .use-note { color: var(--dim); margin-bottom: 6px; }
#usePicker .use-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 10px; }
#usePicker label { display: flex; align-items: center; gap: 5px; min-width: 0; }
#usePicker input { margin: 0; accent-color: var(--accent); }
#usePicker .use-groups { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 10px; padding-bottom: 4px; margin-bottom: 2px; border-bottom: 1px dotted var(--border); }
@media (max-width: 540px) {
  #usePicker { left: 8px; }
  #usePicker .use-grid { grid-template-columns: 1fr; }
  #usePicker .use-groups { grid-column: 1; grid-template-columns: 1fr; }
}

/* ---- layout ---- */
main { flex: 1; display: flex; min-height: 0; }
#palette {
  width: 126px; flex: none; min-height: 0; max-height: calc(100% - 24px); overflow-y: auto;
  align-self: center; margin: 12px; padding: 19px 13px 22px;
  border: 1px solid #9b9da0; border-radius: 34px;
  background: linear-gradient(100deg, #aeb1b5 0%, #eceef0 7%, #d5d8dc 48%, #c2c6ca 92%, #92969b 100%);
  box-shadow: inset 1px 1px 2px #fff, inset -2px -2px 3px #85898e, 0 6px 12px #24282d24;
  scrollbar-width: thin; scrollbar-color: #92969b transparent;
}
#palette h2 { margin: 0 0 13px; text-align: center; color: #585d64; font: 9px/1.2 system-ui, sans-serif; letter-spacing: 2px; }
.palette-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.police-actions { margin-top: 16px; padding-top: 13px; border-top: 1px solid #a6aab0; }
.police-actions .note { display: none; }
button.palette-tool {
  height: 39px; min-width: 0; padding: 0; display: flex; align-items: center; justify-content: center;
  border: 1px solid #17191c; border-radius: 50%;
  background: linear-gradient(#3e4248, #24272c); color: white;
  box-shadow: inset 0 1px 1px #747982, 0 2px 2px #0004;
  text-align: center; cursor: pointer;
}
button.palette-tool:hover:not(.locked) { background: linear-gradient(#545b64, #343a42); }
button.palette-tool.on { background: linear-gradient(#526c62, #2c443a); border-color: #e4fff0; box-shadow: 0 0 0 2px #657a70, inset 0 1px 2px #b8dcc5; }
button.palette-tool:active:not(.locked) { box-shadow: inset 0 2px 4px #0008; }
button.palette-tool:focus-visible { outline: 3px solid #2975b9; outline-offset: 3px; }
button.palette-tool.locked { background: #b4b8bd; border-color: #a5a9ae; box-shadow: inset 0 1px 2px #85899066; cursor: not-allowed; }
.palette-icon { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; color: #e8edf0; pointer-events: none; }
.palette-icon svg { display: block; width: 24px; height: 24px; }
.palette-tool.on .palette-icon { color: #edfff4; }
.palette-tool.locked .palette-icon { color: #545b64; opacity: 0.55; }
#stage { flex: 1; position: relative; min-width: 0; background: var(--map); }
#map { display: block; width: 100%; height: 100%; image-rendering: pixelated; outline: none; cursor: crosshair; }
#panel {
  width: 300px; flex: none; display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: var(--panel);
  min-height: 0;
}
#panel section { padding: 8px 10px; border-bottom: 1px solid var(--border); }
#panel footer { padding: 6px 10px; color: var(--dim); font-size: 10px; line-height: 1.4; border-top: 1px solid var(--border); }

@media (max-height: 719px) {
  #palette { width: 222px; border-radius: 28px; }
  .palette-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1350px) {
  button.tool > span:not(.key) { display: none; }
}

@media (max-width: 980px) {
  #panel { width: 260px; }
  #strip { gap: 3px; }
  #tools { gap: 1px; }
  button.tool { padding-left: 3px; padding-right: 3px; }
  button.tool > span:not(.key) { display: none; }
}

/* ---- stats ---- */
#stats { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
#stats .stat b { font-weight: 600; }
#stats .stat i { font-style: normal; color: var(--dim); }
#stats .stat.bad b { color: var(--bad); }

/* ---- demand bars over the map ---- */
#bars {
  position: absolute; left: 10px; top: 10px;
  display: flex; gap: 6px; padding: 5px 6px 3px;
  background: rgba(246, 244, 236, 0.9); border: 1px solid var(--border);
}
#bars .bar { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#bars .track { position: relative; width: 12px; height: 64px; background: #e4e0d0; border: 1px solid var(--border); }
#bars .zero { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--dim); }
#bars .fill { position: absolute; left: 2px; right: 2px; background: var(--accent); }
#bars .fill.neg { background: var(--bad); }
#bars .tax { position: absolute; left: -2px; right: -2px; height: 1px; background: var(--ink); border-top: 1px dotted #fffdf6; }
#bars .cap { position: absolute; left: -3px; width: 4px; height: 3px; background: var(--warn); }
#bars .lab { color: var(--dim); font-size: 10px; line-height: 1; }

/* ---- flash and banner ---- */
#flash {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  max-width: 70%; padding: 3px 10px;
  background: rgba(246, 244, 236, 0.95); border: 1px solid var(--border);
  color: var(--ink); visibility: hidden;
}
#flash.on { visibility: visible; }
#banner {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 10px;
  background: #b8b4a6; color: #3b382e; border-top: 1px solid var(--border);
  display: none; letter-spacing: 1px;
}
#banner.on { display: block; }

/* ---- hover card ---- */
#card { min-height: 96px; max-height: 190px; overflow: auto; flex: none; }
#card .head b { font-weight: 600; }
#card .head.personhead { display: flex; align-items: flex-start; gap: 7px; }
#card canvas.portrait { width: 32px; height: 32px; flex: none; image-rendering: pixelated; border: 1px solid var(--border); background: #fffdf6; }
#card .personname { min-width: 0; }
#card .dim { color: var(--dim); }
#card .warn { color: var(--warn); }
#card .why b { font-weight: 600; letter-spacing: 1px; }
#card .pin { color: var(--accent); }
#card button.personlink { border: 0; padding: 0; background: transparent; color: var(--accent); font: inherit; text-decoration: underline; text-decoration-style: dotted; }
#card .want { margin: 3px 0; }
#card .doing, #card .epitaph { color: var(--dim); font-style: italic; }
#card .life { margin-top: 4px; border-top: 1px dotted var(--border); padding-top: 3px; }
#card details { margin: 1px 0; }
#card summary { cursor: pointer; }

/* ---- tabs ---- */
#tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); flex: none; }
#tabs .tab {
  flex: 1; border: none; border-right: 1px solid var(--border); background: transparent;
  padding: 4px 0; letter-spacing: 2px; text-transform: uppercase; font-size: 10px; color: var(--dim);
}
#tabs .tab:last-child { border-right: none; }
#tabs .tab.on { color: var(--ink); background: #fffdf6; }
#tabBody { flex: 1; overflow: auto; min-height: 0; }
#tabBody .note { color: var(--dim); margin: 4px 0; }
#tabBody .dim { color: var(--dim); }
#tabBody ol.rules { margin: 0; padding-left: 18px; }
#tabBody ol.rules li { margin: 0 0 6px; }
#tabBody ol.rules b { font-weight: 600; }
#tabBody .formula { color: var(--dim); }
#tabBody .live { color: var(--accent); }
#tabBody table.ledger { border-collapse: collapse; width: 100%; margin: 6px 0; }
#tabBody table.ledger td { padding: 1px 4px 1px 0; vertical-align: top; }
#tabBody table.ledger td.num { text-align: right; white-space: nowrap; }
#tabBody table.ledger tr.h td { border-top: 1px solid var(--border); font-weight: 600; padding-top: 3px; }
#tabBody table.ledger tr.bad td { color: var(--bad); }
#tabBody table.small td { font-size: 11px; }
#tabBody .rates .rate { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
#tabBody .rates .lab { width: 44px; color: var(--dim); }
#tabBody .rates .val { width: 36px; text-align: right; }
#tabBody .rates button { padding: 0 6px; }
#tabBody .hist .hrow { display: flex; align-items: center; gap: 6px; margin: 1px 0; }
#tabBody .hist .lab { width: 64px; color: var(--dim); }
#tabBody .hist .hbar { flex: 1; height: 8px; background: #e4e0d0; border: 1px solid var(--border); }
#tabBody .hist .hfill { height: 100%; background: var(--accent); } /* ui.js paints each species' bar in its coat */
#tabBody .hist .num { width: 34px; text-align: right; }
#tabBody ul.log { list-style: none; margin: 0; padding: 0; }
#tabBody ul.log li { margin: 0 0 3px; border-bottom: 1px dotted var(--border); padding-bottom: 2px; }
#tabBody ul.log li.bad { color: var(--bad); }
#tabBody ul.log li.good { color: var(--accent); }
#tabBody .line { margin-bottom: 4px; }

/* ---- modals ---- */
.modal {
  position: fixed; inset: 0; background: rgba(59, 56, 46, 0.35);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal[hidden] { display: none; }
.modalbox {
  width: 360px; max-width: 92vw; max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); padding: 12px 14px;
}
.modalbox.wide { width: 460px; }
.modalbox h2 { margin-top: 0; }
.modalbox h2 + h2, .modalbox .saves + h2, .modalbox .btnrow + h2 { margin-top: 14px; }
.modalbox p { margin: 6px 0; }
.modalbox .row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.modalbox .row label { color: var(--dim); }
.modalbox input[type=text], .modalbox textarea {
  font: inherit; color: var(--ink); background: #fffdf6; border: 1px solid var(--border); padding: 2px 6px;
  flex: 1; min-width: 0; width: 100%;
}
.modalbox textarea { resize: vertical; margin: 4px 0; }
.modalbox input[type=checkbox] { accent-color: var(--accent); margin: 0; }
.btnrow { display: flex; gap: 6px; margin: 8px 0 0; }
.saves .save { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; }
.saves .save b { font-weight: 600; max-width: 100%; overflow-wrap: anywhere; }
.saves .save .dim { flex: 1; color: var(--dim); }

/* ---- the title screen (js/title.js): the owner's painting under the name,
   the menu on a parchment bar along the bottom, one card for the panels.
   The painting is 1424×848; "center top / cover" keeps the skyline and the
   faces in view at any aspect and crops the coats first. ---- */
[hidden] { display: none !important; }
#title {
  position: fixed; inset: 0; z-index: 20;
  background: #2b2723 url("../img/titlescreen.png") center top / cover no-repeat;
  display: flex; flex-direction: column; align-items: center;
}
#title .mast { margin-top: 4vh; text-align: center; color: #f6f4ec; text-shadow: 0 2px 0 #1a1714, 0 0 18px rgba(18, 14, 10, 0.8); }
#title h1 { font-size: clamp(30px, 5.4vw, 72px); letter-spacing: 0.3em; margin: 0 0 0 0.3em; font-weight: 600; line-height: 1.1; }
#title .tag { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: #ece5d3; margin-top: 10px; }
#title .tcard { margin-top: 3vh; max-height: 60vh; background: rgba(246, 244, 236, 0.97); box-shadow: 0 6px 24px rgba(18, 14, 10, 0.35); }
#title .tbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 10px 16px;
  background: rgba(246, 244, 236, 0.94); border-top: 1px solid var(--border);
}
#title .tmenu { display: flex; flex-wrap: wrap; gap: 6px; }
#title .tmenu button { padding: 5px 14px; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
#title .tnote { flex: 1 1 240px; color: var(--dim); }
#title .tfoot { color: var(--dim); font-size: 10px; letter-spacing: 1px; }
.modalbox .note { color: var(--dim); }
#stats button.cheat { padding: 0 6px; }

/* ---- the news reader (js/news.js) ----
   Every dispatch the city ever made, oldest first, with a cursor you step.
   The strip button carries the unread count and goes ink-filled while any
   stands, the same way pause / overlay / zoom show they are on. ---- */
#news .newsbox {
  width: 660px; max-width: 94vw; max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.newstop { display: flex; align-items: baseline; gap: 8px; }
.newstop h2 { flex: 1; margin: 0; }
.newstop button { padding: 0 7px; }
.newshead { margin: 2px 0 7px; }
.newschips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.newschips .chip {
  font: inherit; color: var(--dim); background: transparent;
  border: 1px solid var(--border); padding: 1px 7px; letter-spacing: 1px;
}
.newschips .chip.on { color: #fffdf6; background: var(--ink); border-color: var(--ink); }
ul.newsfeed {
  list-style: none; margin: 0; padding: 3px 0; flex: 1; min-height: 140px; overflow: auto;
  background: #fffdf6; border: 1px solid var(--border);
}
ul.newsfeed li.note { color: var(--dim); padding: 6px 10px; }
li.nrow { display: flex; gap: 6px; padding: 2px 8px 2px 2px; align-items: baseline; cursor: default; }
li.nrow .gut { width: 12px; flex: none; text-align: center; color: var(--accent); }
li.nrow .when { width: 96px; flex: none; color: var(--dim); }
li.nrow .txt { flex: 1; min-width: 0; }
li.nrow .txt b { font-weight: 600; letter-spacing: 1px; }
li.nrow .person-link {
  appearance: none; border: 0; border-bottom: 1px dotted currentColor;
  padding: 0; color: inherit; background: transparent; font: inherit;
  cursor: pointer;
}
li.nrow .person-link:hover, li.nrow .person-link:focus-visible { color: var(--ink); outline: 1px solid currentColor; outline-offset: 2px; }
li.nrow.bad .txt { color: var(--bad); }
li.nrow.good .txt { color: var(--accent); }
li.nrow.report .txt { color: var(--dim); }
li.nrow.unread .when { color: var(--ink); }
li.nrow.at { background: #ece7d6; }
li.nrow.at .gut { color: var(--ink); }
.newsfoot { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.newsfoot .dim { flex: 1; text-align: center; color: var(--dim); }

.found-actions { align-items: center; justify-content: space-between; }
.found-actions .primary { min-height: 42px; padding: 10px 18px; font-size: 14px; }
.found-actions .found-back { margin-left: auto; }

.city-modes { border: 1px solid var(--border); margin: 12px 0; padding: 8px 10px; }
.city-modes legend { color: var(--dim); padding: 0 5px; }
.city-mode { display: flex; align-items: flex-start; gap: 9px; padding: 8px 4px; cursor: pointer; }
.city-mode input { margin: 3px 0 0; flex: 0 0 auto; }
.city-mode strong, .city-mode .note { display: block; }
.city-mode strong { margin-bottom: 3px; }
.city-mode:has(input:checked) strong { color: var(--accent); }

/* Persistent policy controls remain readable in the narrow field guide. */
#tabs { flex-wrap: wrap; }
.governance-policy { padding: 10px 0; border-top: 1px solid var(--border); }
.governance-policy h3, .governance-outcomes h3 { margin: 0 0 5px; font-size: 12px; }
.governance-policy p { margin: 4px 0 8px; }
.governance-policy select { max-width: calc(100% - 70px); margin: 0 6px 6px 0; font: inherit; }
.governance-policy button { margin-bottom: 6px; }
.governance-outcomes { border-top: 2px solid var(--border); padding-top: 12px; }
