/* Line of Departure - css/game.css
 * A staff-map palette: drab paper, olive and rust for the two sides, and no
 * decoration that competes with the map for attention.
 */

:root {
  --paper: #14170f;
  --panel: #1c2016;
  --panel-2: #232819;
  --line: #3a4230;
  --ink: #dfe3d2;
  --ink-dim: #9aa287;
  --ink-faint: #6d7459;
  --alliance: #4d82c0;
  --alliance-dim: #2c4c72;
  --union: #c05a4d;
  --union-dim: #72332c;
  --accent: #c9a227;
  --warn: #d0803a;
  --good: #7fa650;
  --shadow: 0 2px 10px rgba(0, 0, 0, .55);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  overscroll-behavior: none;
}

.screen { display: none; position: fixed; inset: 0; }
.screen.visible { display: block; }

h1, h2 { font-weight: 600; letter-spacing: .01em; margin: 0 0 .4em; }
h1 { font-size: 1.7rem; }
h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-dim); }
p { margin: 0 0 .8em; }
a { color: var(--accent); }

button, select, input {
  font: inherit; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 3px; padding: .42em .8em; cursor: pointer;
}
button:hover:not(:disabled) { background: #2c3220; border-color: #55603f; }
button:disabled { opacity: .38; cursor: not-allowed; }
button.primary { background: var(--alliance-dim); border-color: var(--alliance); }
button.primary:hover:not(:disabled) { background: #34588180; }
button:focus-visible, canvas:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input { cursor: text; }

.note { color: var(--ink-faint); font-size: .85rem; }
.note.small { font-size: .78rem; }
.meta { color: var(--ink-dim); font-size: .85rem; }
.situation { color: var(--ink-dim); font-style: italic; }

/* ---- loading ------------------------------------------------------------ */
/* An id selector beats .screen, so these base rules must NOT set display or
 * the screen is shown permanently and its canvas swallows every click meant
 * for the menu underneath it. Only the .visible rule turns a screen on. */
#loading { place-items: center; background: var(--paper); }
#loading.visible { display: grid; }
.loading-inner { text-align: center; max-width: 30rem; padding: 2rem; }
.loading-inner .sub { color: var(--ink-faint); letter-spacing: .18em; text-transform: uppercase; font-size: .72rem; }
.bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 1.6rem 0 .8rem; }
#loadbar { height: 100%; width: 4%; background: var(--accent); transition: width .25s ease; }

/* ---- menu --------------------------------------------------------------- */
#menu { overflow: auto; }
.menu-inner { max-width: 68rem; margin: 0 auto; padding: 2.4rem 1.4rem 4rem; }
#menu header { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1.4rem; }
#menu header .sub { color: var(--ink-faint); margin: 0; }
.menu-body { display: grid; grid-template-columns: minmax(15rem, 22rem) 1fr; gap: 2rem; }
.list { list-style: none; margin: 0 0 1.4rem; padding: 0; }
.list li { margin: 0 0 .4rem; }
.list button {
  display: block; width: 100%; text-align: left; padding: .6em .8em; background: var(--panel);
}
.list button.on { border-color: var(--accent); background: #2a2f1d; }
.list .li-name { display: block; }
.list .li-sub { display: block; color: var(--ink-faint); font-size: .78rem; }
.detail { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 1.2rem 1.4rem; }
.controls { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: 1.2rem 0 .8rem; }
.controls label { color: var(--ink-dim); font-size: .82rem; }
#seed { width: 8rem; }
.buttons { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .4rem; }

/* ---- game --------------------------------------------------------------- */
#game { grid-template-rows: auto 1fr; grid-template-columns: 1fr 21rem; grid-template-areas: "hud hud" "board side"; }
#game.visible { display: grid; }

#hud {
  grid-area: hud; display: flex; align-items: center; gap: 1.2rem;
  padding: .5rem .9rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.hud-left, .hud-mid { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.hud-right { margin-left: auto; display: flex; gap: .45rem; }
.hud-right button { padding: .35em .7em; }
.badge { font-size: .8rem; color: var(--accent); letter-spacing: .08em; text-transform: uppercase; }
.stat { display: flex; flex-direction: column; line-height: 1.1; }
.stat b { font-family: var(--mono); font-size: 1.02rem; }
.stat i { font-style: normal; font-size: .64rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); }
.stat.cp b { color: var(--accent); }

#board { grid-area: board; position: relative; overflow: hidden; background: #0e1109; }
#map { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#mapnote {
  position: absolute; left: .7rem; bottom: .7rem; max-width: 34rem;
  background: rgba(12, 14, 8, .86); border: 1px solid var(--line); border-radius: 3px;
  padding: .35rem .6rem; font-size: .82rem; color: var(--ink-dim); pointer-events: none;
}
#zoomers { position: absolute; right: .7rem; bottom: .7rem; display: flex; flex-direction: column; gap: .3rem; }
#zoomers button { width: 2.1rem; height: 2.1rem; padding: 0; }

#side {
  grid-area: side; background: var(--panel); border-left: 1px solid var(--line);
  overflow: auto; padding: .9rem; display: flex; flex-direction: column; gap: 1rem;
}
#side section { border-bottom: 1px solid var(--line); padding-bottom: .9rem; }
#side section:last-child { border-bottom: 0; }
#unit-name { font-size: 1.02rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
#unit-stats { display: grid; grid-template-columns: auto 1fr; gap: .18rem .7rem; margin: .6rem 0; font-size: .84rem; }
#unit-stats dt { color: var(--ink-faint); }
#unit-stats dd { margin: 0; font-family: var(--mono); }
.meter { display: block; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: .25rem; }
.meter span { display: block; height: 100%; }

#orders { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; margin-top: .5rem; }
#orders button { padding: .38em .3em; font-size: .8rem; text-align: center; }
#orders button.armed { border-color: var(--accent); background: #2f3420; }

#net-list { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
#net-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .12rem 0; }
#net-list .lk { font-family: var(--mono); font-size: .75rem; }
.lk-digital { color: var(--good); }
.lk-voice { color: var(--ink-dim); }
.lk-degraded { color: var(--warn); }
.lk-runner, .lk-none { color: var(--union); }

#log-list { list-style: none; margin: 0; padding: 0; font-size: .8rem; max-height: 15rem; overflow: auto; }
#log-list li { padding: .18rem 0; border-bottom: 1px solid #262b1c; color: var(--ink-dim); }
#log-list li .t { font-family: var(--mono); color: var(--ink-faint); margin-right: .4rem; }
#log-list li.k-fire { color: var(--ink); }
#log-list li.k-loss { color: var(--union); }
#log-list li.k-objective { color: var(--accent); }
#log-list li.k-event { color: var(--warn); }

/* ---- after action -------------------------------------------------------- */
#after { place-items: center; background: rgba(8, 10, 5, .93); }
#after.visible { display: grid; }
.after-inner {
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  padding: 1.8rem 2rem; max-width: 34rem; box-shadow: var(--shadow);
}
#after-stats { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: 1rem 0 1.4rem; font-size: .88rem; }
#after-stats dt { color: var(--ink-faint); }
#after-stats dd { margin: 0; font-family: var(--mono); }

/* ---- toast --------------------------------------------------------------- */
#toast {
  position: fixed; left: 50%; bottom: 1.6rem; transform: translateX(-50%) translateY(1rem);
  background: #2a2f1d; border: 1px solid var(--accent); border-radius: 3px;
  padding: .5rem .9rem; font-size: .86rem; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 40; max-width: 90vw;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- narrow screens ------------------------------------------------------ */
@media (max-width: 860px) {
  .menu-body { grid-template-columns: 1fr; }
  #game { grid-template-columns: 1fr; grid-template-rows: auto 1fr minmax(0, auto); grid-template-areas: "hud" "board" "side"; }
  #side { border-left: 0; border-top: 1px solid var(--line); max-height: 44vh; }
  #hud { flex-wrap: wrap; gap: .7rem; }
  .hud-right { width: 100%; margin-left: 0; }
  #log-list { max-height: 8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
