/* base-hunter shared theme, used by panel.html and map.html.
   Look: Minecraft Java UI greys, light bevelled buttons and hard pixel drop shadows (after shop.og.place),
   with pixel headings, inventory slots and grass-green accents (after mergemc.net).
   Everything is drawn with CSS. Fonts are self-hosted under the SIL OFL 1.1:
   Monocraft (fonts/Monocraft-OFL.txt) and Press Start 2P (fonts/PressStart2P-OFL.txt). */

@font-face {
  font-family: "Monocraft";
  src: url("fonts/Monocraft.otf") format("opentype");
  font-display: swap;
}
@font-face {
  font-family: "Press Start 2P";
  src: url("fonts/PressStart2P-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --mc: "Monocraft", ui-monospace, monospace;               /* Minecraft-style UI text */
  --pixel: "Press Start 2P", "Monocraft", ui-monospace, monospace;   /* big blocky headings */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;   /* long prose */
  --mono: "Monocraft", ui-monospace, "JetBrains Mono", monospace;

  /* Greys from the game's own UI. */
  --bg: #141414;
  --bg-deep: #0c0c0c;
  --topbar: #282828;
  --surface: #282828;
  --surface-2: #323232;
  --surface-3: #3c3c3c;
  --well: #191919;
  --outline: #000;
  --line: #3c3c3c;
  --line-soft: rgba(255, 255, 255, .06);

  --ink: #e6e6e6;
  --muted: #aaaaaa;
  --dim: #6e6e6e;

  /* Chat formatting colours. */
  --mc-green: #55ff55;
  --mc-dark-green: #00aa00;
  --mc-gold: #ffaa00;
  --mc-yellow: #ffff55;
  --mc-red: #ff5555;
  --mc-dark-red: #aa0000;
  --mc-aqua: #55ffff;
  --mc-dark-aqua: #00aaaa;
  --mc-blue: #5555ff;
  --mc-purple: #ff55ff;

  --green: #36b836;
  --green-dark: #41850a;
  --lime: #2bf32b;
  --grass: var(--mc-green);
  --gold: var(--mc-gold);
  --red: var(--mc-red);
  --orange: #ff8c1a;
  --blue: #7fa7ff;
  --cyan: var(--mc-aqua);

  --button: #c8c8c8;
  --button-down: #646464;
  --slot: #8b8b8b;
  --slot-dark: #373737;
  --slot-lit: #ffffff;

  /* Bevels: light top/left edge, dark bottom/right edge. */
  --bevel-soft:
    linear-gradient(to top, rgba(0, 0, 0, .3) 2px, transparent 2px),
    linear-gradient(to left, rgba(0, 0, 0, .3) 2px, transparent 2px),
    linear-gradient(to right, rgba(255, 255, 255, .06) 2px, transparent 2px),
    linear-gradient(to bottom, rgba(255, 255, 255, .06) 2px, transparent 2px);
  --drop: 5px 5px 0 rgba(0, 0, 0, .5);           /* hard pixel shadow: things float */
  --drop-up: 8px 8px 0 rgba(0, 0, 0, .5);
  --topbar-h: 56px;
  color-scheme: dark;
}

/* The bevel is computed per element so `--bevel-w` can be overridden locally. */
.btn, button, .badge, .bevel {
  --bevel-w: 3px;
  --bevel-img:
    linear-gradient(to top, rgba(0, 0, 0, .28) var(--bevel-w), transparent var(--bevel-w)),
    linear-gradient(to left, rgba(0, 0, 0, .28) var(--bevel-w), transparent var(--bevel-w)),
    linear-gradient(to right, rgba(255, 255, 255, .28) var(--bevel-w), transparent var(--bevel-w)),
    linear-gradient(to bottom, rgba(255, 255, 255, .28) var(--bevel-w), transparent var(--bevel-w));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* a `display` rule must never override the hidden attribute */
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--mc);
  -webkit-font-smoothing: none;
}
a { color: var(--gold); }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
code { color: var(--gold); background: var(--bg-deep); padding: 1px 5px; }
.pixel { font-family: var(--pixel); font-weight: 400; line-height: 1.5; }
.prose { font-family: var(--sans); -webkit-font-smoothing: antialiased; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; }
.shadowed { text-shadow: 2px 2px 0 rgba(0, 0, 0, .55); }

/* Bevel helper for any block. */
.bevel { background-image: var(--bevel-img); background-repeat: no-repeat; background-position: left bottom, right top, left top, left top; }

/* ---------- top bar: shared header and navigation ---------- */

.topbar {
  position: sticky; top: 0; z-index: 900;
  height: var(--topbar-h);
  display: flex; align-items: stretch; gap: 18px;
  padding: 0 16px;
  background: var(--topbar);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .45);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font: 13px var(--pixel); color: var(--ink); text-decoration: none; white-space: nowrap;
  text-shadow: 2px 2px 0 #000;
}
.brand b { color: var(--grass); font-weight: 400; }
.brand-mark {
  width: 24px; height: 24px; flex: none;
  /* a tiny grass block */
  background:
    linear-gradient(90deg, transparent 25%, rgba(0, 0, 0, .2) 25% 37%, transparent 37% 62%, rgba(0, 0, 0, .2) 62% 75%, transparent 75%) 0 10px / 100% 4px no-repeat,
    linear-gradient(90deg, transparent 12%, rgba(255, 255, 255, .12) 12% 25%, transparent 25% 75%, rgba(0, 0, 0, .15) 75% 88%, transparent 88%) 0 15px / 100% 4px no-repeat,
    linear-gradient(#6cc349 0 30%, #4c9a2f 30% 40%, #8a5a36 40% 70%, #6b4429 70%);
  box-shadow: 2px 2px 0 #000;
}
.tabs { display: flex; align-items: flex-end; gap: 4px; }
.tab {
  display: flex; align-items: center; gap: 8px; height: 44px;
  padding: 0 18px; color: var(--muted); text-decoration: none; font-size: 16px;
  text-shadow: 2px 2px 0 #000;
}
.tab:hover { color: var(--ink); background: rgba(255, 255, 255, .04); }
.tab.active {
  color: #fff; background: var(--bg);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .12), inset -3px 0 0 rgba(0, 0, 0, .3);
}
.tab .key { font-size: 11px; color: var(--dim); }
.topbar-status { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
body:not(.signed-in) .needs-auth { display: none !important; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 9px; color: var(--muted); font-size: 13px;
  background: var(--bg-deep);
}
.chip b { color: var(--ink); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ---------- buttons and inputs ---------- */

.btn, button {
  --b-bg: var(--button); --b-ink: #141414; --b-hover: var(--green-dark);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 5px 13px 8px; min-height: 34px;
  font: 15px/1 var(--mc); color: var(--b-ink); cursor: pointer; white-space: nowrap;
  background-color: var(--b-bg);
  background-image: var(--bevel-img); background-repeat: no-repeat;
  background-position: left bottom, right top, left top, left top;
  border: 0; border-radius: 0;
  user-select: none;
}
.btn:not(:disabled):hover, button:not(:disabled):hover { color: var(--b-hover); }
.btn:not(:disabled):active, button:not(:disabled):active { background-color: var(--button-down); background-image: none; color: var(--lime); }
.btn:focus-visible, button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.btn:disabled, button:disabled { background-color: #505050; background-image: none; color: #8c8c8c; cursor: not-allowed; }
.btn.primary, button.primary { --b-bg: var(--green); --b-ink: #fff; --b-hover: var(--mc-yellow); text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); }
.btn.danger, button.danger { --b-bg: var(--mc-dark-red); --b-ink: #fff; --b-hover: var(--mc-yellow); text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); }
.btn.ghost, button.ghost { --b-bg: var(--surface-3); --b-ink: var(--ink); --b-hover: var(--mc-green); text-shadow: 2px 2px 0 rgba(0, 0, 0, .5); }
.btn.small, button.small { min-height: 28px; padding: 3px 9px 6px; font-size: 13px; --bevel-w: 2px; }
.btn.icon, button.icon { min-width: 34px; padding-left: 6px; padding-right: 6px; }
.btn.confirm, button.confirm { --b-bg: var(--gold); --b-ink: #2a1500; --b-hover: #000; }

input, select, textarea {
  width: 100%; padding: 6px 9px; min-height: 34px;
  font: 15px var(--mc); color: #fff;
  background: #000; border: 2px solid #a0a0a0; border-radius: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #fff; }
input::placeholder { color: #707070; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--green); }

label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); cursor: pointer; }
label.check input { width: auto; margin: 0; }

/* ---------- panels ---------- */

.mc-panel {
  background-color: var(--surface);
  background-image: var(--bevel-soft); background-repeat: no-repeat;
  background-position: left bottom, right top, left top, left top;
  box-shadow: var(--drop);
}
.section-label {
  font: 10px/1.5 var(--pixel); text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 10px; margin: 0;
  text-shadow: 2px 2px 0 #000;
}
.note { padding: 9px 12px; color: var(--gold); background: rgba(255, 170, 0, .08); box-shadow: inset 3px 0 0 var(--gold); }
.error { color: var(--red); min-height: 1em; margin: 6px 0 0; }

/* State badges, shared by cards, sheet and map. */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 7px 5px; font: 13px/1 var(--mc); white-space: nowrap;
  color: #000; background-color: #777;
  background-image: var(--bevel-img); background-repeat: no-repeat; background-position: left bottom, right top, left top, left top;
}
.badge { --bevel-w: 2px; }
.badge.s-ACTIVE { background-color: var(--mc-green); }
.badge.s-ATTACHED { background-color: #4fd17a; }
.badge.s-HELD { background-color: var(--mc-aqua); }
.badge.s-QUEUED { background-color: var(--mc-yellow); }
.badge.s-KICK_READY { background-color: var(--orange); animation: blink 1s steps(2) infinite; }
.badge.s-OFFLINE { background-color: #555; color: #ddd; }
.badge.s-STALE { background-color: #3c3c3c; color: var(--muted); }
@keyframes blink { 50% { filter: brightness(1.35); } }

.tag {
  display: inline-block; padding: 1px 6px 2px; font-size: 13px; line-height: 1.4;
  color: var(--muted); background: var(--bg-deep);
  text-transform: lowercase;
}
.tag.gold { color: var(--gold); }
.tag.cyan { color: var(--cyan); }
.tag.green { color: var(--grass); }

/* Inventory slot. */
.slot {
  position: relative; display: inline-grid; place-items: center; flex: none;
  background: var(--slot);
  box-shadow: inset 2px 2px 0 var(--slot-dark), inset -2px -2px 0 var(--slot-lit);
}
.pix { image-rendering: pixelated; shape-rendering: crispEdges; display: block; }

/* Player heads, with a coloured block when the skin service can't be reached. */
.head { display: inline-grid; place-items: center; overflow: hidden; flex: none; background: var(--surface-3); }
.head img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.head .head-fallback { font-family: var(--pixel); color: rgba(0, 0, 0, .55); width: 100%; height: 100%; display: grid; place-items: center; }
.user-head img { image-rendering: auto; }
button.chip.who { cursor: pointer; border: 0; font: inherit; font-size: 13px; }
button.chip.who:hover, button.chip.who:focus-visible { color: var(--ink); outline: 2px solid var(--accent, #55ff55); outline-offset: -2px; }
.profile-preview { display: grid; place-items: center; margin: 4px 0 12px; }
.profile-preview .head { box-shadow: 0 0 0 2px #000, 4px 4px 0 rgba(0, 0, 0, .5); }

/* ---------- dialogs, sign-in gate, toasts ---------- */

dialog {
  color: var(--ink); padding: 22px; width: min(460px, calc(100vw - 24px)); border: 0;
  background: var(--surface);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, .6), inset 0 0 0 2px #000, inset 4px 4px 0 rgba(255, 255, 255, .07), inset -4px -4px 0 rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { font: 14px/1.4 var(--pixel); margin: 0 0 14px; text-shadow: 2px 2px 0 #000; }
dialog p { font-size: 14px; }
dialog label { display: block; margin: 10px 0; color: var(--muted); font-size: 14px; }
dialog label input, dialog label select { margin-top: 4px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* App pages show nothing (no top bar, no map controls) until the session is confirmed; login.html is the
   only thing a signed-out visitor sees. */
body:not(.signed-in):not(.login-page) > :not(.toasts) { visibility: hidden !important; }

/* Controls the signed-in user may not use (app.js sets one can-* class per permission). */
body:not(.can-fleet-control) [data-perm~="fleet.control"],
body:not(.can-planner-edit) [data-perm~="planner.edit"],
body:not(.can-accounts-manage) [data-perm~="accounts.manage"],
body:not(.can-accounts-tokens) [data-perm~="accounts.tokens"],
body:not(.can-users-manage) [data-perm~="users.manage"],
body:not(.can-fleet-read) [data-perm~="fleet.read"],
body:not(.can-map-read) [data-perm~="map.read"] { display: none !important; }

/* ---------- sign-in page ---------- */

body.login-page {
  min-height: 100vh; margin: 0; display: grid; place-items: center; padding: 20px;
  background: #04070a;
}
/* End portal effect behind the sign-in box (void.js), drawn small and scaled up pixelated. */
#void { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; image-rendering: pixelated; display: block; }
.login-card { width: min(380px, calc(100vw - 40px)); padding: 26px; display: grid; gap: 12px; justify-items: center; box-shadow: 6px 6px 0 rgba(0, 0, 0, .6); }
.login-card > input, .login-card > button, .login-card .login-state { width: 100%; }
.login-icon { width: 56px; height: 56px; margin-bottom: 4px; }
.login-state { display: grid; gap: 12px; justify-items: center; text-align: center; }
.login-card [hidden] { display: none !important; }
.login-status { font: 12px/1.6 var(--pixel); margin: 4px 0 0; text-shadow: 2px 2px 0 #000; color: var(--mc-yellow); }
.login-status.denied { color: var(--mc-red); }
.login-status.expired { color: var(--muted); }
.login-state button { width: 100%; }
/* Countdown, drawn like the game's XP bar. */
.login-timer { width: 100%; height: 10px; background: #000; box-shadow: inset 0 0 0 2px #2b2b2b; }
.login-timer > span { display: block; height: 100%; width: 100%; background: var(--lime); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3); transition: width 1s linear; }
.login-card .error:empty { display: none; }

/* ---------- lend page (hosted players) ---------- */

.lend-card { width: min(480px, calc(100vw - 32px)); }
.lend-title { font: 14px/1.5 var(--pixel); margin: 0; color: var(--ink); text-shadow: 2px 2px 0 #000; }
.lend-step { display: grid; gap: 12px; width: 100%; }
.lend-for { margin: 0; text-align: center; }
.lend-facts { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 14px; line-height: 1.45; }
.lend-facts b { color: var(--mc-yellow); }
.lend-field { display: grid; gap: 6px; font-size: 14px; }
.lend-check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.4; cursor: pointer; }
.lend-check input { margin-top: 2px; }
.lend-step > button, .lend-login > .btn { width: 100%; }
.lend-login > .btn { text-decoration: none; }
.lend-login { display: grid; gap: 10px; justify-items: center; text-align: center; }
.lend-login p { margin: 0; }
.lend-code { --b-bg: #000; --b-ink: var(--mc-yellow); font-size: 28px; letter-spacing: 4px; padding: 10px 16px 12px; min-height: 0; }
.lend-ends { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
#lend-phase { text-align: center; }
#lend-done { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.toasts {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1000;
  display: flex; flex-direction: column-reverse; align-items: center; gap: 6px; pointer-events: none;
}
/* Like chat lines in the game. */
.toast {
  pointer-events: auto; max-width: min(620px, 92vw); padding: 6px 12px 8px;
  color: #fff; background: rgba(0, 0, 0, .78); font-size: 15px; text-shadow: 2px 2px 0 #3f3f3f;
  animation: toast-in .15s steps(3);
}
.toast.ok { color: var(--mc-green); }
.toast.bad { color: var(--mc-red); }
.toast.warn { color: var(--mc-yellow); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

* { scrollbar-width: thin; scrollbar-color: #555 transparent; }

@media (max-width: 760px) {
  :root { --topbar-h: 50px; }
  .topbar { gap: 6px; padding: 0 8px; }
  .brand { font-size: 0; gap: 0; }
  .tab { padding: 0 12px; height: 40px; font-size: 15px; }
  .topbar-status { display: none; }
  .label-wide { display: none; }
}
