/* THORNMERE chrome — colors drawn from data/art/palette.json */

/* Period typography (OFL fonts bundled under assets/fonts/, licenses alongside):
   Pirata One — blackletter display, HEADERS ONLY (plaques, data-titles, keycaps).
   IM Fell English — old-style serif body for prose (log, status, hints).
   Monospace stays on column-aligned surfaces (menu, roster). */
@font-face {
  font-family: 'Pirata One';
  src: url('assets/fonts/PirataOne-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('assets/fonts/IMFellEnglish-Regular.ttf') format('truetype');
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('assets/fonts/IMFellEnglish-Italic.ttf') format('truetype');
  font-weight: normal; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'MedievalSharp';
  src: url('assets/fonts/MedievalSharp-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --font-display: 'Pirata One', 'MedievalSharp', 'Times New Roman', serif;
  --font-body: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --font-mono: 'Courier New', ui-monospace, monospace;

  --black: #000000;
  --night: #16121e;
  --shadow: #2c2836;
  --slate-dark: #46424f;
  --slate: #6a6675;
  --stone: #928e9e;
  --bone: #c4c2cc;
  --chalk: #eeeef2;
  --umber: #482c1a;
  --leather: #74482a;
  --amberwood: #a06e3c;
  --honey: #cc9a58;
  --parchment: #ecc890;
  --moss: #265222;
  --fen-green: #3e8434;
  --leaf: #72c04c;
  --deep-blue: #1e3c74;
  --sky-blue: #3a6cb8;
  --mist-blue: #a8d2ec;
  --blood: #84222a;
  --ember: #c84032;
  --flame: #ee7a4e;
  --gold-dark: #8a5c18;
  --gold: #d8a224;
  --candle: #f8d878;
  --violet: #8a52c8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--night);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 15px;
  height: 100%;
}

body { display: flex; align-items: center; justify-content: center; }

#game {
  width: 1100px;
  background: var(--black);
  /* ornate thorn-vine frame (assets/chrome/chrome_frame.png, 72×72 9-slice) */
  border: 24px solid transparent;
  border-image: url('assets/chrome/chrome_frame.png') 24 round;
  image-rendering: pixelated;
  padding: 12px;
  box-shadow: 0 0 50px rgba(216, 162, 36, 0.12);
}

#toprow { display: flex; gap: 10px; }

#viewwrap { position: relative; }

#view {
  display: block;
  background: #000;
  /* 320x240 internal framebuffer at an exact 2x integer scale: chunky pixels */
  width: 640px;
  height: 480px;
  image-rendering: pixelated;
  border: 2px solid var(--gold-dark);
}

/* viewport movement arrows: mouse parity for ↑ ← → ↓ */
.nav {
  position: absolute;
  color: var(--candle);
  background: var(--umber);
  /* carved button bevel (assets/chrome/chrome_button.png) */
  border: 8px solid transparent;
  border-image: url('assets/chrome/chrome_button.png') 8 stretch;
  image-rendering: pixelated;
  padding: 1px 8px;
  cursor: pointer;
  user-select: none;
  opacity: 0;
  transition: opacity 0.12s;
  font-size: 16px;
}
#viewwrap:hover .nav { opacity: 0.8; }
.nav:hover { opacity: 1 !important; color: var(--chalk); }
.nav:active { border-image: url('assets/chrome/chrome_button_down.png') 8 stretch; }
#nav-up    { top: 8px; left: 50%; transform: translateX(-50%); }
#nav-down  { bottom: 28px; left: 50%; transform: translateX(-50%); }
#nav-left  { left: 8px; top: 50%; transform: translateY(-50%); }
#nav-right { right: 8px; top: 50%; transform: translateY(-50%); }

/* carved nameplate plaque under the viewport (assets/chrome/chrome_plaque.png) */
#loc {
  margin: 8px auto 0;
  width: max-content;
  max-width: 90%;
  min-width: 140px;
  text-align: center;
  color: var(--candle);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 1px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 6px 22px;
  border: 8px solid transparent;
  border-image: url('assets/chrome/chrome_plaque.png') 8 fill repeat;
  image-rendering: pixelated;
}
#loc:empty { display: none; }

#right { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* titled panels — slim carved bevel border (assets/chrome/chrome_panel.png) */
.panel {
  position: relative;
  border: 8px solid transparent;
  border-image: url('assets/chrome/chrome_panel.png') 8 stretch;
  image-rendering: pixelated;
}
.panel::before {
  content: attr(data-title);
  position: absolute;
  top: -13px;
  left: 8px;
  background: var(--black);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1;
  letter-spacing: 1px;
  padding: 0 6px;
  z-index: 1;
}
.panel[data-title="·"]::before { content: none; }

#status {
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--bone);
  min-height: 58px;
  display: flex;
  gap: 10px;
  align-items: center;
}
#status .stat-text { white-space: pre-wrap; flex: 1; min-width: 0; }
#status canvas { image-rendering: pixelated; display: block; }
#status .gold { color: var(--gold); }
#status .songname { color: var(--candle); }
#status .effects { color: var(--mist-blue); }

#menu {
  padding: 6px 8px;
  margin-top: 10px;
  /* monospace: character sheets, stat rolls and the victory company table
     align their columns with space-padding */
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--parchment);
  min-height: 30px;
  /* don't let the EVENTS log squeeze the menu below its own cap: a clipped
     menu hides clickable options (the Options/Custom screens once did this) */
  flex-shrink: 0;
  max-height: 320px;
  overflow-y: auto;
}
#menu:empty { display: none; }
#menu .title { color: var(--gold); }
#menu .ctx { color: var(--stone); }
#menu .opt { cursor: pointer; display: inline; }
#menu .opt.eq    { color: var(--chalk); }   /* equipped — bright white, scans first */
#menu .opt.held  { color: var(--stone); }   /* carried but not readied — muted grey */
#menu .grouphead { color: var(--amberwood); letter-spacing: 1px; }  /* Equipped / Pack labels */
#menu .opt:hover { color: var(--candle); background: var(--shadow); }
#menu .opt .key { color: var(--gold); }
#menu .opt.dim { color: var(--slate); cursor: default; }
#menu .opt.dim:hover { background: none; }

#log {
  margin-top: 16px;   /* clearance for the taller display-font EVENTS plaque tab */
  padding: 6px 8px;
  flex: 1;
  overflow-y: auto;
  /* serif prose narration — the most period-feeling text surface */
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  min-height: 90px;
  max-height: 330px;
  color: var(--bone);
}
#log .mouth { color: var(--gold); }
#log .hurt { color: var(--flame); }
#log .good { color: var(--leaf); }
#log .party { color: var(--mist-blue); }
#log .loot { color: var(--candle); }
#log p { margin: 0 0 2px 0; }
/* each narrated line eases in as it scrolls into the log */
#log p.reveal { animation: logreveal 200ms ease-out; }
@keyframes logreveal {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}

#roster {
  margin-top: 12px;
  padding: 6px 8px;
  /* monospace: roster cells pad names/numbers to fixed widths for column alignment */
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.0;
  min-height: 158px;
}
#roster .hdr { color: var(--slate); font-size: 11px; letter-spacing: 1px; }
#roster .row {
  display: grid;
  grid-template-columns: 14px 22px 18px 160px 44px 110px 110px 150px 36px 1fr;
  align-items: center;
  gap: 4px;
  padding: 1px 2px;
  cursor: pointer;
  white-space: pre;
}
#roster .row:hover { background: var(--night); }
#roster .row.empty { color: var(--shadow); cursor: default; }
#roster .row canvas { image-rendering: pixelated; display: block; }
#roster .num { color: var(--slate); }
#roster .row.pick { background: var(--shadow); outline: 1px solid var(--gold-dark); }
/* condition colors, as the original did it */
#roster .ok       { color: var(--parchment); }
#roster .wounded  { color: var(--candle); }
#roster .critical { color: var(--flame); }
#roster .poisoned { color: var(--leaf); }
#roster .numb     { color: var(--slate); }
#roster .dead     { color: var(--blood); text-decoration: line-through; }
#roster .summon   { color: var(--mist-blue); font-style: italic; }
#roster .sp       { color: var(--sky-blue); }
#roster .flags    { color: var(--ember); font-size: 11px; }
/* steady edge bar for an ongoing affliction (the transient hit flash is a row
   background set inline by the renderer; box-shadow keeps the two from clashing) */
#roster .row.st-poison { box-shadow: inset 3px 0 0 var(--fen-green); }
#roster .row.st-stone  { box-shadow: inset 3px 0 0 #5a6c8a; }
#roster .row.st-fear   { box-shadow: inset 3px 0 0 var(--gold); }

#cmdbar {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
}
#cmdbar button {
  background: var(--umber);
  color: var(--parchment);
  /* carved-wood button bevel (assets/chrome/chrome_button.png) */
  border: 8px solid transparent;
  border-image: url('assets/chrome/chrome_button.png') 8 stretch;
  image-rendering: pixelated;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 2px 9px;
  cursor: pointer;
}
/* hover = candle-glow text, never a background swap */
#cmdbar button:hover { color: var(--candle); }
#cmdbar button:active { border-image: url('assets/chrome/chrome_button_down.png') 8 stretch; }
#cmdbar button kbd {
  padding: 0 4px;
  margin-right: 5px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 14px;
}

#hint {
  margin-top: 6px;
  color: var(--slate);
  font-size: 12px;
  min-height: 16px;
  white-space: pre-wrap;
}

::-webkit-scrollbar { width: 8px; background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--slate-dark); }
