/* style.css — hi-bit interface.
   Panels, cards, buttons, tabs and bars are drawn with frames cut from the
   sprite sheet (see installUiSkin in src/sprites.js). Each ui_* sprite becomes
   a CSS variable like --ui-button, used below with `border-image`.
   The numbers after each one are the frame thickness in pixels
   (top right bottom left) and must match how the sprite was drawn. */

/* ---------- Fonts (bundled in assets/fonts, SIL Open Font License) ---------- */
@font-face { font-family: 'Jersey 10'; font-weight: 400; src: url(assets/fonts/jersey-10-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Silkscreen'; font-weight: 400; src: url(assets/fonts/silkscreen-latin-400-normal.woff2) format('woff2'); }

:root {
  /* Colours, matched to the sprite palette (tools/build_sprites.py) */
  --page: #b8d8f0;
  --ink: #2e222f;          /* outline colour */
  --text: #3e3546;
  --muted: #6e6680;
  --plum: #803e68;
  --brown: #a26442;
  --good: #2f8a5a;
  --bad: #c8304a;
  --gold: #fcc848;
  --blue: #4682d2;
  --green: #46aa6e;
  --orange: #f49646;

  --body: 'Jersey 10', system-ui, sans-serif;
  --label: 'Silkscreen', 'Jersey 10', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page); color: var(--text);
  font-family: var(--body); font-size: 21px; line-height: 1.2; letter-spacing: .3px;
  display: flex; flex-direction: column;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "clig" 0;
}
h2, h3 { font-family: var(--body); font-weight: 400; margin: 12px 0 8px; }
h2 { font-size: 28px; color: var(--plum); }
h3 { font-size: 21px; color: var(--brown); text-transform: uppercase; letter-spacing: 1px; }
label { font-family: var(--label); font-size: 11px; color: var(--muted); text-transform: uppercase; }
.small { font-size: 19px; }
.muted { color: var(--muted); }
.pos, .good { color: var(--good); }
.neg, .bad { color: var(--bad); }
.sprite { display: inline-block; image-rendering: pixelated; background-repeat: no-repeat; vertical-align: middle; }

/* ---------- Frames from the sprite sheet ---------- */
.dialog, .title-card, .tipbox, .toast, #hud, #panel, #ticker {
  border-style: solid; border-width: 8px 8px 10px 8px;
  border-image: var(--ui-panel) 8 8 10 8 fill / 8px 8px 10px 8px stretch;
  image-rendering: pixelated;
}
.card, .cc-preview, .pick {
  border-style: solid; border-width: 6px;
  border-image: var(--ui-card) 6 fill / 6px stretch;
  image-rendering: pixelated;
}
.card.offer.dubious, .toast.bad { border-image-source: var(--ui-card-red); }
.card.offer.righteous, .card.owned, .toast.good { border-image-source: var(--ui-card-green); }
.card.selected { border-image-source: var(--ui-card-gold); }
.toast.good, .toast.bad { border-width: 6px; border-image-slice: 6 fill; border-image-width: 6px; }

button {
  font-variant-ligatures: none;
  font-family: var(--body); font-weight: 400; font-size: 19px; color: var(--ink); letter-spacing: .5px;
  background: none; padding: 1px 6px; cursor: pointer;
  border-style: solid; border-width: 6px 6px 10px 6px;
  border-image: var(--ui-button) 6 6 10 6 fill / 6px 6px 10px 6px stretch;
  image-rendering: pixelated;
}
button:hover:not(:disabled) { border-image-source: var(--ui-button-hover); }
button:active:not(:disabled) { border-image-source: var(--ui-button-down); transform: translateY(2px); }
button.on { border-image-source: var(--ui-button-on); }
button.danger { border-image-source: var(--ui-button-danger); }
button:disabled { border-image-source: var(--ui-button-off); color: var(--muted); cursor: not-allowed; }
button:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }

.pick { text-align: left; font-family: var(--body); font-weight: 400; font-size: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 2px 6px; transform: none !important; }
.pick:hover:not(:disabled) { border-image-source: var(--ui-card-gold); }
.pick:active:not(:disabled) { border-image-source: var(--ui-card-gold); }
.pick.on { border-image-source: var(--ui-button-on); }
.pick:disabled { border-image-source: var(--ui-card); opacity: .5; }

input {
  font-family: var(--body); font-size: 22px; color: var(--text); background: none; padding: 2px 6px;
  border-style: solid; border-width: 6px; border-image: var(--ui-input) 6 fill / 6px stretch; image-rendering: pixelated;
}
input:focus { outline: 2px dashed var(--orange); outline-offset: 2px; }

.bar, .meter {
  border-style: solid; border-width: 4px; background: none;
  border-image: var(--ui-track) 4 fill / 4px stretch; image-rendering: pixelated;
}
.bar { flex: 1; min-width: 60px; height: 16px; }
.meter { width: 140px; height: 18px; }
.bar > div, .meter > div { height: 100%; background: var(--blue); box-shadow: inset 0 2px 0 rgba(255,255,255,.35); }
.bar.energy > div { background: var(--green); }
.bar.xp > div { background: var(--orange); }
.skill .bar.xp { flex: none; min-width: 0; width: 30px; height: 10px; border-width: 3px; border-image-width: 3px; }
.meter > div { transition: width .3s; }

/* ---------- HUD ---------- */
#hud { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 4px 10px; margin: 8px 16px 0; }
.firm #firmName { font-size: 26px; color: var(--plum); }
.firm #date { color: var(--muted); font-size: 19px; }
.stat { display: flex; align-items: center; gap: 8px; }
.stat.col { flex-direction: column; align-items: flex-start; gap: 2px; }
#cash { font-size: 26px; color: var(--good); }
#cash.neg { color: var(--bad); }
#stars { display: flex; gap: 1px; }
.morality { display: flex; align-items: center; gap: 6px; }
.speed { margin-left: auto; display: flex; gap: 4px; }
.speed button { min-width: 44px; font-family: system-ui, sans-serif; font-size: 13px; }

/* ---------- Layout ---------- */
main { flex: 1; display: flex; gap: 16px; padding: 12px 16px 16px; min-height: 0; }
#scene { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
#office {
  width: 100%; max-width: 960px; aspect-ratio: 640 / 384; display: block;
  image-rendering: pixelated; border: 4px solid var(--ink); border-radius: 4px; background: #96d2f4; cursor: pointer;
}
.hint { margin: 6px 0; }
#panel { flex: 0 0 440px; display: flex; flex-direction: column; min-height: 0; padding: 0; }
#tabs { display: flex; gap: 2px; padding: 4px 4px 0; border-bottom: 2px solid var(--ink); }
#tabs button {
  flex: 1; padding: 4px 2px 2px; font-size: 20px;
  border-width: 6px 6px 2px 6px; border-image: var(--ui-tab) 6 6 2 6 fill / 6px 6px 2px 6px stretch;
}
#tabs button.on { border-image-source: var(--ui-tab-on); }
#tabs button:hover:not(.on) { border-image-source: var(--ui-tab-on); filter: saturate(.6) brightness(1.08); }
#tabs button:active { transform: none; }
#tabBody { overflow-y: auto; padding: 4px 10px 12px; flex: 1; }

/* ---------- News feed (scrollable, last few weeks) ---------- */
#ticker { margin-top: 8px; max-width: 960px; padding: 0; }
#ticker .feed-head { display: flex; justify-content: space-between; align-items: center; padding: 0 6px; }
#feed { max-height: 132px; min-height: 60px; overflow-y: auto; padding: 0 6px 2px; }
#feed .item { padding: 2px 0; border-bottom: 1px dashed #e0d6c6; display: flex; gap: 10px; }
#feed .item .when { font-family: var(--label); font-size: 10px; color: var(--muted); white-space: nowrap; padding-top: 4px; min-width: 64px; }
#feed .empty { color: var(--muted); padding: 4px 0; }
.log { padding: 2px 0; }

/* Chunky pixel scrollbars (Safari and Chrome) */
#feed::-webkit-scrollbar, #tabBody::-webkit-scrollbar, .dialog::-webkit-scrollbar { width: 14px; }
#feed::-webkit-scrollbar-track, #tabBody::-webkit-scrollbar-track, .dialog::-webkit-scrollbar-track { background: #e9e4ef; border-left: 2px solid var(--ink); }
#feed::-webkit-scrollbar-thumb, #tabBody::-webkit-scrollbar-thumb, .dialog::-webkit-scrollbar-thumb {
  background: #78bef4; border: 2px solid var(--ink); border-bottom-width: 4px;
}
#feed::-webkit-scrollbar-thumb:hover, #tabBody::-webkit-scrollbar-thumb:hover { background: var(--gold); }
#feed, #tabBody, .dialog { scrollbar-color: #78bef4 #e9e4ef; }

/* ---------- Cards ---------- */
.card { padding: 4px 6px; margin: 8px 0; }
.card.locked { opacity: .55; }
.card.offer:not(.locked) { cursor: pointer; }
.card.offer:not(.locked):hover { filter: brightness(1.03) drop-shadow(0 2px 0 rgba(46,34,47,.25)); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 3px 0; }
.row.meta { justify-content: flex-start; gap: 4px 14px; }
.badge {
  font-family: var(--label); font-size: 10px; padding: 1px 5px 2px; background: #645e70; color: #fffcf6;
  white-space: nowrap; border: 2px solid var(--ink); border-radius: 3px; text-transform: uppercase;
}
.badge.dubious { background: var(--bad); }
.badge.righteous { background: var(--good); }
.need { margin-right: 6px; white-space: nowrap; }
.skills { display: flex; gap: 10px; flex-wrap: wrap; }
.skill { display: inline-flex; align-items: center; gap: 2px; }
.prog { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.faces .sprite { margin-right: 2px; }

/* ---------- Modal ---------- */
#modal { position: fixed; inset: 0; background: rgba(46,34,47,.45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
#modal[hidden] { display: none; }
.dialog { position: relative; padding: 8px 14px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; }
.dialog .close { position: absolute; top: 4px; right: 4px; padding: 0 6px; font-family: system-ui, sans-serif; }
.paused-chip {
  display: inline-block; font-family: var(--label); font-size: 10px; background: var(--orange); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 3px; padding: 1px 6px; margin-bottom: 4px;
}
.picks { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.pick .skills { margin-left: auto; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
table.needs { border-collapse: collapse; margin: 8px 0; }
table.needs td, table.needs th { padding: 2px 12px 2px 0; text-align: left; }
table.needs th { font-family: var(--label); font-size: 10px; font-weight: normal; color: var(--muted); text-transform: uppercase; }
.evhead { display: flex; align-items: center; gap: 10px; }

/* ---------- Character creator ---------- */
.creator { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin: 12px 0 14px; }
.cc-grid { display: grid; grid-template-columns: 40px 140px 40px minmax(120px, auto); grid-template-rows: 44px 36px 80px; column-gap: 6px; align-items: center; }
.cc-preview { width: 140px; height: 172px; display: flex; align-items: center; justify-content: center; align-self: start; }
.cc-arrow { padding: 0; width: 40px; font-family: system-ui, sans-serif; font-size: 12px; }
.cc-label { padding-left: 8px; font-size: 21px; }
.cc-colours { display: flex; flex-direction: column; gap: 6px; }
.swatches { display: grid; grid-template-columns: repeat(4, 28px); gap: 6px; }
.swatch { width: 28px; height: 28px; padding: 0; border: 2px solid var(--ink); border-radius: 3px; border-image: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3); }
.swatch:hover:not(:disabled) { border-image: none; transform: translateY(-1px); }
.swatch:active:not(:disabled) { border-image: none; }
.swatch.on { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 20; pointer-events: none; }
.toast { padding: 4px 8px; max-width: 360px; transition: opacity .6s; color: var(--text); }
.toast.fade { opacity: 0; }

/* ---------- Title screen ---------- */
#title { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px; }
#title[hidden] { display: none; }
#titleBg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.title-card { position: relative; text-align: center; padding: 16px 32px 20px; width: min(560px, 100%); }
#titleCast { display: flex; justify-content: center; gap: 4px; margin-bottom: 4px; }
#titleCast .bob { animation: bob 1.2s steps(2) infinite; }
#titleCast .bob:nth-child(2n) { animation-delay: .6s; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.title-card h1 {
  font-family: var(--body); font-weight: 400; font-size: clamp(44px, 10vw, 76px); line-height: .95; letter-spacing: 2px;
  color: var(--plum); text-shadow: 3px 3px 0 var(--orange), 6px 6px 0 var(--ink); margin: 8px 0 14px; text-transform: uppercase;
}
#titleIcons { display: flex; justify-content: center; gap: 16px; }
.by { font-family: var(--label); font-size: 12px; color: var(--muted); margin: 14px 0 20px; text-transform: uppercase; }
.menu { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.menu button { font-size: 26px; padding: 2px 20px; width: 260px; }
#saveHint { margin: 0; color: var(--muted); }

/* ---------- Guided tour ---------- */
#tour { position: fixed; inset: 0; z-index: 30; cursor: pointer; }
#tour[hidden] { display: none; }
#tour .spot {
  position: fixed; border: 3px dashed var(--gold); border-radius: 4px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(46,34,47,.55); transition: all .25s;
}
#tour .spot.none { left: 50%; top: 50%; width: 0; height: 0; border: 0; }
.tipbox { position: fixed; width: min(380px, calc(100vw - 16px)); padding: 6px 12px; }
.tipbox.center { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 16px)); }
.tipbox h2 { margin-top: 2px; }
.tipbox p { margin: 6px 0; }
.tipbox .actions { justify-content: space-between; }
.tipcount { font-family: var(--label); font-size: 10px; color: var(--muted); }

@media (max-width: 1000px) {
  main { flex-direction: column; }
  #panel { flex-basis: auto; }
}
