/* ArcticMUD web client. Dark, like the terminals the game's colors were made for. */
:root {
  color-scheme: dark;
  --font-size: 15px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --bg: #0f1115;
  --panel: #171a21;
  --field: #0b0d11;
  --border: #2a2f3a;
  --text: #c8ccd4;
  --muted: #8a909c;
  --accent: #6cb6ff;
  --echo: #d7ba7d;
  /* the 16 ANSI colors; "black" text is lifted to gray so it stays readable */
  --c0: #555a63;  --c1: #cd3131;  --c2: #0dbc79;  --c3: #e5e510;
  --c4: #3b78d8;  --c5: #bc3fbc;  --c6: #11a8cd;  --c7: #d4d4d4;
  --c8: #7a7f89;  --c9: #f14c4c;  --c10: #23d18b; --c11: #f5f543;
  --c12: #5b9bf0; --c13: #d670d6; --c14: #29b8db; --c15: #ffffff;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "header header" "main panels" "strip strip" "input input";
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.status::before { content: "● "; }
.status[data-state="connected"]::before { color: #3fb950; }
.status[data-state="connecting"]::before { color: #d29922; }
.status[data-state="disconnected"]::before { color: #f85149; }

nav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

button {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #222733;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover { background: #2a3040; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#connect { background: #1f3b61; border-color: #2f5c96; }

main { grid-area: main; position: relative; min-height: 0; }

#output {
  height: 100%;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: var(--font-size);
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 8;
}
#output:focus { outline: none; }
.line { min-height: 1.35em; }

#more-below {
  position: absolute;
  right: 20px;
  bottom: 12px;
  background: #1f3b61;
  border-color: #2f5c96;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.5);
}

#input-form {
  grid-area: input;
  padding: 8px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

#command {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: var(--font-size);
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 6px;
}
#command:focus { outline: none; border-color: var(--accent); }

/* ANSI colors, bold and friends (js/ansi.js) */
.fg0 { color: var(--c0); }   .fg1 { color: var(--c1); }   .fg2 { color: var(--c2); }   .fg3 { color: var(--c3); }
.fg4 { color: var(--c4); }   .fg5 { color: var(--c5); }   .fg6 { color: var(--c6); }   .fg7 { color: var(--c7); }
.fg8 { color: var(--c8); }   .fg9 { color: var(--c9); }   .fg10 { color: var(--c10); } .fg11 { color: var(--c11); }
.fg12 { color: var(--c12); } .fg13 { color: var(--c13); } .fg14 { color: var(--c14); } .fg15 { color: var(--c15); }
.bg0 { background: #000; }   .bg1 { background: var(--c1); }   .bg2 { background: var(--c2); }   .bg3 { background: var(--c3); }
.bg4 { background: var(--c4); }   .bg5 { background: var(--c5); }   .bg6 { background: var(--c6); }   .bg7 { background: var(--c7); }
.bg8 { background: var(--c8); }   .bg9 { background: var(--c9); }   .bg10 { background: var(--c10); } .bg11 { background: var(--c11); }
.bg12 { background: var(--c12); } .bg13 { background: var(--c13); } .bg14 { background: var(--c14); } .bg15 { background: var(--c15); }
.fg-inverse { color: var(--bg); }
.bg-inverse { background: var(--text); }
.bold { font-weight: 700; }
.dim { opacity: 0.7; }
.italic { font-style: italic; }
.underline { text-decoration: underline; }

.echo { color: var(--echo); }
.notice { color: var(--muted); font-style: italic; }

dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 16px 20px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
dialog h2 { margin: 0 0 8px; font-size: 17px; }
dialog p { color: var(--muted); }

textarea {
  width: 100%;
  padding: 8px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
}

code { font-family: var(--mono); background: var(--field); padding: 1px 4px; border-radius: 4px; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 12px; }
dt { font-family: var(--mono); color: var(--accent); }
dd { margin: 0; }

.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#aliases-save { background: #1f3b61; border-color: #2f5c96; }

/* Panels (js/panels.js): a sidebar, hidden until the game sends GMCP data */
#panels {
  grid-area: panels;
  display: flex;
  flex-direction: column;
  width: 280px;
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--panel);
  border-left: 1px solid var(--border);
}
#panels[data-open="false"],
#panels:not(:has(.panel:not([hidden]))) { display: none; }
#panels.stale, #vitals-strip.stale { opacity: 0.5; }
.panel + .panel { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.panel h2 { margin: 0 0 2px; font-size: 14px; }
.panel p { margin: 2px 0; }
.muted { color: var(--muted); font-size: 12px; }
#room-name { font-weight: 600; }
.exits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.exits button { padding: 3px 10px; }
.door { padding: 3px 0; font-size: 12px; color: var(--muted); }
#group-members { display: grid; gap: 10px; margin: 6px 0 0; padding: 0; list-style: none; }
.member.away { opacity: 0.6; }
.member-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.leader { color: #e3b341; }
.tag { padding: 0 6px; font-size: 11px; font-weight: 400; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; }
.tag.fighting { color: #ff7b72; border-color: #8b2d2a; }

/* map (js/map.js): rooms colored by terrain, you in the ring; dashed links
   are one way, amber bars closed doors, triangles up and down */
#map { display: block; width: 100%; height: 176px; margin-top: 6px; background: var(--field); border: 1px solid var(--border); border-radius: 6px; }
#map.lost { opacity: 0.4; }
#map .link, #map .stub { stroke: #4b5263; stroke-width: 2; }
#map .link.one-way { stroke-dasharray: 3 2; }
#map .door { stroke: #d29922; stroke-width: 2; }
#map .room { fill: #8a909c; stroke: rgb(0 0 0 / 0.5); stroke-width: 1; }
#map .env-inside { fill: #6e7681; }
#map .env-city { fill: #b1bac4; }
#map .env-courtyard { fill: #a5a08f; }
#map .env-road { fill: #c9a86a; }
#map .env-path { fill: #b08d57; }
#map .env-trail { fill: #8f7045; }
#map .env-field { fill: #8fd16a; }
#map .env-plains { fill: #bcd66a; }
#map .env-garden { fill: #56d364; }
#map .env-forest { fill: #2ea043; }
#map .env-jungle { fill: #1a7f37; }
#map .env-hills { fill: #c69026; }
#map .env-mountain { fill: #9a6b41; }
#map .env-desert { fill: #e3c16f; }
#map .env-beach { fill: #f2dfa7; }
#map .env-tundra { fill: #e6edf3; }
#map .env-marsh { fill: #7d8b3a; }
#map .env-swamp { fill: #5b6b2a; }
#map .env-water_swim { fill: #58a6ff; }
#map .env-water_noswim { fill: #2f6fdb; }
#map .env-sea { fill: #1f4f9e; }
#map .env-underwater { fill: #3b3f99; }
#map .env-air { fill: #b6e3ff; }
#map .env-subterranean { fill: #6e5a8a; }
#map .env-cavern { fill: #8a6fb0; }
#map .room.unexplored { fill: none; stroke: #4b5263; stroke-dasharray: 2 2; }
#map .walk { cursor: pointer; }
#map .walk:hover { stroke: var(--text); stroke-width: 2; }
#map .updown { fill: var(--text); stroke: var(--field); stroke-width: 0.75; pointer-events: none; }
#map .updown.closed { fill: #d29922; }
#map .you { fill: none; stroke: var(--accent); stroke-width: 2; pointer-events: none; }

/* chat: fills what's left of the panels and scrolls on its own */
#panel-chat { display: flex; flex: 1; flex-direction: column; min-height: 160px; }
#panel-chat[hidden] { display: none; }
#chat-lines { flex: 1; min-height: 120px; margin: 6px 0 0; padding: 0; overflow-y: auto; list-style: none; font-size: 12px; }
.chat-line { padding: 2px 0; line-height: 1.35; overflow-wrap: anywhere; }
.chat-line time { margin-right: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chat-channel { margin-right: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.channel-tell .chat-channel { color: #d670d6; }
.channel-whisper .chat-channel, .channel-ask .chat-channel { color: #b392f0; }
.channel-gtell .chat-channel { color: #3fb950; }
.channel-ctell .chat-channel, .channel-otell .chat-channel { color: #79c0ff; }
.channel-shout .chat-channel, .channel-yell .chat-channel { color: #f0883e; }
.channel-wiz .chat-channel, .channel-god .chat-channel, .channel-ggod .chat-channel,
.channel-chat .chat-channel { color: #e3b341; }
#panels-button.unread::after { content: " •"; color: var(--accent); }

/* bars: health colored in the game's own bands (80% / 20%), moves blue */
.bar {
  position: relative;
  height: 18px;
  margin: 4px 0;
  overflow: hidden;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: #1f6feb; transition: width 0.3s ease; }
.bar .fill.good { background: #238636; }
.bar .fill.hurt { background: #9e6a03; }
.bar .fill.bad { background: #b62324; }
/* line-heights are the bar's height less its 2px of border */
.bar .label {
  position: relative;
  display: block;
  padding: 0 6px;
  font: 12px/16px var(--mono);
  color: #fff;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.8);
  white-space: nowrap;
}
.bar.small { height: 14px; margin: 3px 0; }
.bar.small .label { font-size: 11px; line-height: 12px; }
#vitals-strip { grid-area: strip; display: none; }

/* Narrow screens: the panels become a drawer over the game text, and thin
   health and moves bars sit above the command line. */
@media (max-width: 900px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "header" "main" "strip" "input"; }
  #panels {
    grid-area: main;
    justify-self: end;
    z-index: 5;
    width: min(300px, 85vw);
    box-shadow: -4px 0 16px rgb(0 0 0 / 0.5);
  }
  #vitals-strip:not([hidden]) {
    display: flex;
    gap: 8px;
    padding: 6px 12px 0;
    background: var(--panel);
    border-top: 1px solid var(--border);
  }
  #vitals-strip .bar { flex: 1; height: 14px; margin: 0; }
  #vitals-strip .bar .label { font-size: 11px; line-height: 12px; }
  #vitals-strip:not([hidden]) + #input-form { border-top: none; }
}

@media (max-width: 600px) {
  h1 { display: none; }
  header { gap: 8px; padding: 6px 8px; }
  nav { gap: 4px; }
  nav button { padding: 4px 8px; }
  #output { padding: 6px 8px; }
  #input-form { padding: 6px 8px; }
}
