/* World War Hex. The staff table, broadcast: baize for the cloth, eight flat channels for everything
   printed on it, block graphics for every object. Nothing here is a bordered rectangle standing in for a
   thing: the plate, the card and the keys are generated rasters, nine sliced on their measured edges, and
   the grain each one carries is a repeating tile, never a stretched middle. */

@font-face { font-family: Departure; src: url("/assets/fonts/departure-mono.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: Oswald; src: url("/assets/fonts/oswald-400-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Oswald; src: url("/assets/fonts/oswald-600-latin.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: Elite; src: url("/assets/fonts/special-elite-latin.woff2") format("woff2"); font-display: swap; }

:root {
  --field: #0B1A13;
  --baize: #10261C;
  --ivory: #F2EBDD;
  --paper: #E9DFC6;
  --brass: #C79A42;
  --brass-dim: #8A6A2C;
  --felt: #1C5137;
  --signal: #5BC8C8;
  --pot-ink: #E07CC0;
  --war-ink: #F07A6A;
  --war: #C2362B;
  --neutral: #6E8BD8;
  --line: #7D6E52;
  --edge: #2B2B2B;
  --muted: #A9BCAF;
  --ink: #3A3630;
  --ink-dim: #5A5247;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --t-head: 22px;
  --t-value: 22px;
  --t-body: 16px;
  --t-ticker: 17px;
  --page: min(1720px, 100vw - 64px);
  --rail: 96px;
  --card: 460px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--field); overflow-x: clip; }
body {
  margin: 0;
  padding: 0 0 var(--s8);
  background: var(--baize) url("/assets/img/baize.png") repeat;
  background-size: 48px 48px;
  color: var(--ivory);
  font: 400 var(--t-body)/1.6 Oswald, "Arial Narrow", sans-serif;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
/* the lamp over the table: the room's own light, on its own clock, never on the pointer */
body::before {
  content: ""; position: fixed; inset: -20vh -20vw; z-index: 0; pointer-events: none;
  background: radial-gradient(42vw 38vh at 50% 34%, rgba(255, 226, 164, .11), rgba(255, 226, 164, .04) 46%, transparent 72%);
  animation: lamp 96s ease-in-out infinite alternate;
}
@keyframes lamp {
  0%   { transform: translate3d(-3.5vw, -1.5vh, 0) scale(1); }
  50%  { transform: translate3d(2vw, 2vh, 0) scale(1.06); }
  100% { transform: translate3d(4vw, -2vh, 0) scale(1.02); }
}

.skip { position: absolute; left: -9999px; }
.skip { color: var(--signal); }
.skip:focus { left: var(--s4); top: var(--s4); z-index: 20; background: var(--brass); color: var(--field); padding: var(--s3) var(--s5); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.page { width: var(--page); margin: 0 auto; position: relative; z-index: 1; }

/* ---- the broadcast's header: his test card, with his black ink over it ----- */
.masthead {
  position: relative;
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s3) calc(var(--s3) + 20px);
  margin-bottom: var(--s5);
  background: url("/assets/img/colour-bars.png") 0 0 / 100% 100% no-repeat;
  image-rendering: pixelated;
  /* the test card runs the full width of the glass, as it does in his picture */
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding-left: calc(50vw - 50% + var(--s3)); padding-right: calc(50vw - 50% + var(--s3));
}
.masthead::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22px;
  background: url("/assets/img/band-dither.png") 0 100% / 100% 100% no-repeat; image-rendering: pixelated;
}
.markbox { display: inline-flex; align-items: center; background: var(--field); padding: 10px var(--s4); }
.pageno {
  font-family: Departure, monospace; font-size: var(--t-head); line-height: 1; letter-spacing: 0.08em;
  color: var(--signal); background: var(--field); padding: 18px 24px; align-self: stretch;
  display: flex; align-items: center;
}
.wordmark { height: 96px; width: auto; image-rendering: pixelated; }
.standings { display: flex; gap: 2px; margin: 0 0 0 auto; padding: 0; align-self: stretch; }
.standings div { text-align: right; background: var(--field); padding: 14px var(--s5); display: flex; flex-direction: column; justify-content: center; }
.standings dt { font: 600 var(--t-body)/1.2 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; color: var(--signal); margin: 0 0 2px; }
.standings dd { font-family: Departure, monospace; font-size: var(--t-value); line-height: 1.3; margin: 0; color: var(--ivory); }
.v-war { color: var(--war-ink); }
.v-peace { color: var(--paper); }
.v-state { color: var(--brass); }

/* ---- the table ------------------------------------------------------------ */
.table { display: flex; align-items: stretch; gap: var(--s4); }

.rail {
  width: var(--rail); flex: 0 0 var(--rail);
  display: flex; flex-direction: column; align-items: center;
  background: var(--field); padding: var(--s4);
}
.rail-name { font: 600 var(--t-body)/1.2 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; margin: 0; color: var(--signal); }
.rail-count { font-family: Departure, monospace; font-size: var(--t-value); line-height: 1.3; margin: var(--s1) 0 0; }
.rail-war .rail-count { color: var(--war-ink); }
.rail-peace .rail-count { color: var(--paper); }
.rail-sub { font-size: var(--t-body); color: var(--muted); margin: 0; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.rail-sub b { display: block; font-weight: 400; font-family: Departure, monospace; color: var(--ivory); }
.rail-bar { flex: 1 1 auto; width: 100%; min-height: 140px; display: block; image-rendering: pixelated; margin: var(--s3) 0; }

.mapwrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.map-view { width: 100%; max-width: 100%; overflow: hidden; display: flex; justify-content: center; }
/* when the board is bigger than its window the drag is the only thing that positions it */
.map-view.draggable { justify-content: flex-start; cursor: grab; }
.map-view.draggable:active { cursor: grabbing; }
#map { display: block; image-rendering: pixelated; cursor: pointer; touch-action: none; }
.maphint { margin: var(--s3) 0 0; font-size: var(--t-body); color: var(--muted); min-height: 26px; text-align: center; }

/* ---- the order card: a generated sheet, nine sliced on its own edges ------- */
/* the sheet ends where its content ends: stretching it to the map's height leaves a field of blank
   paper under the last line, which reads as a hole rather than as air */
.card { width: var(--card); flex: 0 0 var(--card); align-self: flex-start; display: flex; flex-direction: column; min-width: 0; }
.index { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s1); margin-bottom: var(--s2); }
.ix {
  text-align: center;
  font: 600 var(--t-body)/1.15 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--signal); background: var(--field); border: 0; cursor: pointer;
  padding: var(--s3) var(--s2); min-height: 60px;
}
.ix b { font-family: Departure, monospace; font-weight: 400; font-size: var(--t-body); display: block; letter-spacing: 0.04em; }
.ix:nth-child(1) b { color: var(--signal); }
.ix:nth-child(2) b { color: var(--brass); }
.ix:nth-child(3) b { color: #6FD39B; }
.ix:nth-child(4) b { color: var(--pot-ink); }
.ix:nth-child(5) b { color: #8FA6EC; }
.ix[aria-current="page"] b { color: var(--field); }
.ix:hover { background: var(--felt); }
.ix[aria-current="page"] { background: var(--brass); color: var(--field); }
.ix[aria-current="page"] b { color: var(--field); }

.card-body {
  flex: 1 1 auto; min-width: 0;
  background: var(--paper) url("/assets/img/paper-grain.png") repeat;
  border-image: url("/assets/img/order-card.png") 14 8 8 20 / 14px 8px 8px 20px / 0 stretch;
  color: var(--edge);
  padding: var(--s3) var(--s5) var(--s6) var(--s5);
}
.card-body > :first-child { margin-top: 0; }
.card-body { min-height: 380px; }

/* ---- the caption bar: his picture's device, used for every heading --------- */
.bar {
  position: relative;
  font: 400 var(--t-head)/1 Departure, monospace; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ivory); background: var(--field);
  margin: var(--s6) 0 var(--s4); padding: 15px var(--s5);
}
.bar::after {
  content: ""; position: absolute; left: 100%; top: 0; width: 56px; height: 100%; max-width: 100%;
  background: url("/assets/img/bar-tail.png") left center / auto 100% no-repeat; image-rendering: pixelated;
}
.card-body .bar { margin-left: calc(var(--s5) * -1); margin-right: calc(var(--s5) * -1); }
.card-body .bar::after { display: none; }
.band .bar::after { display: none; }

.lede { margin: 0 0 var(--s4); font-size: var(--t-body); line-height: 1.55; color: var(--ink); }
.note { margin: var(--s3) 0 0; font-size: var(--t-body); line-height: 1.5; color: var(--ink-dim); }
.band .note { color: var(--muted); }

/* ---- a number is always a label and a value in one row -------------------- */
.rows { margin: 0 0 var(--s4); padding: 0; }
.rows > div { display: flex; align-items: baseline; gap: var(--s3); padding: 10px 0; position: relative; }
.rows > div + div::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--line); opacity: .5; }
.rows dt { flex: 0 0 46%; font: 600 var(--t-body)/1.3 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); margin: 0; }
.rows dd { flex: 1 1 auto; min-width: 0; margin: 0; font-family: Departure, monospace; font-size: var(--t-value); color: var(--edge); overflow-wrap: anywhere; }
.card-body .v-war { color: #9E281E; }
.card-body .v-peace { color: #5E5648; }

/* ---- keys ----------------------------------------------------------------- */
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 52px; padding: 14px 22px;
  font: 600 var(--t-body)/1 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em;
  border: 0; cursor: pointer; text-decoration: none;
  border-image: url("/assets/img/key-brass.png") 8 fill / 8px / 0 stretch;
  color: var(--field);
  transition: filter .12s, transform .08s;
}
.key.wide { display: flex; width: 100%; }
.key:hover { filter: brightness(1.12); }
.key:active { transform: translateY(2px); }
.key-war { border-image-source: url("/assets/img/key-war.png"); color: var(--ivory); }
.key-peace { border-image-source: url("/assets/img/key-peace.png"); color: var(--edge); }
.key-dark { border-image-source: url("/assets/img/key-dark.png"); color: var(--ivory); }
.key[aria-disabled="true"], .key:disabled { opacity: .74; cursor: not-allowed; }
.key[aria-disabled="true"]:hover, .key:disabled:hover { filter: none; }
.key[aria-disabled="true"]:active, .key:disabled:active { transform: none; }

.sides { display: flex; gap: var(--s3); margin-bottom: var(--s4); }
.sides .key { flex: 1 1 0; }

.field { display: block; font: 600 var(--t-body)/1.3 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); margin-bottom: var(--s2); }
.input {
  width: 100%; min-height: 52px; padding: 0 var(--s5);
  font: 400 var(--t-value)/1 Departure, monospace; color: var(--edge);
  background: #DCD0B2; border: 2px solid var(--line);
}
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s3) 0 var(--s4); }
.chip {
  flex: 1 1 64px; min-height: 52px; padding: 0 var(--s4);
  font: 400 var(--t-body)/1 Departure, monospace; color: var(--edge);
  background: #DCD0B2; border: 2px solid var(--line); cursor: pointer;
}
.chip:hover { background: var(--brass); }
.chip[aria-pressed="true"] { background: var(--brass); border-color: var(--edge); }

.claims { list-style: none; margin: 0 0 var(--s4); padding: 0; }
.claims li { position: relative; display: flex; align-items: center; gap: var(--s3); padding: var(--s4) 0; }
.claims li + li::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--line); opacity: .5; }
.claims .amt { font-family: Departure, monospace; font-size: var(--t-value); flex: 1 1 auto; }
.battles { list-style: none; margin: var(--s4) 0 0; padding: 0; }
.battles li { position: relative; padding: var(--s4) 0; font-size: var(--t-body); line-height: 1.55; color: var(--ink); }
.battles li + li::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--line); opacity: .5; }
.battles code { overflow-wrap: anywhere; }
#gauge { display: block; width: 100%; height: auto; image-rendering: pixelated; margin: var(--s3) 0 0; background: var(--field); }

.steps { margin: 0; padding: 0 0 0 var(--s5); }
.steps li { margin-bottom: var(--s3); font-size: var(--t-body); line-height: 1.55; color: var(--ink); }
.steps b { font-weight: 600; color: var(--edge); }
code { font-family: Departure, monospace; font-size: var(--t-body); }
.cmd { font-family: Departure, monospace; font-size: var(--t-body); background: var(--field); color: var(--signal); padding: var(--s4) var(--s5); margin: var(--s3) 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- the teletype --------------------------------------------------------- */
.teletype { display: flex; align-items: stretch; gap: 0; margin-top: var(--s5); }
.tt-label {
  display: flex; align-items: center; padding: 0 var(--s5);
  font: 600 var(--t-body)/1 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--signal); color: var(--field); min-height: 60px;
}
.tt-win { flex: 1 1 auto; min-width: 0; background: var(--field); display: flex; align-items: center; padding: var(--s3) var(--s5); min-height: 60px; }
.tt-line { margin: 0; font: 400 var(--t-ticker)/1.4 Elite, "Courier New", monospace; color: var(--brass); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- the maker's plate ---------------------------------------------------- */
.plate {
  margin-top: var(--s5);
  background: var(--brass) url("/assets/img/brass-grain.png") repeat;
  border-image: url("/assets/img/brass-plate.png") 28 / 28px / 0 stretch;
  padding: var(--s5) var(--s6) var(--s6);
  color: var(--field);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4) var(--s5);
}
.plate-head { width: 100%; margin: 0; font: 600 18px/1.3 Oswald, sans-serif; letter-spacing: 0.02em; color: #3C2E12; }
.plate-ca { flex: 1 1 420px; min-width: 0; display: flex; align-items: center; gap: var(--s4); background: #4A3718; padding: var(--s2) var(--s2) var(--s2) var(--s5); }
.ca-label { font: 600 var(--t-body)/1.2 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; color: #E8C271; }
.ca { flex: 1 1 auto; min-width: 0; font-family: Departure, monospace; font-size: var(--t-value); color: var(--ivory); overflow-wrap: anywhere; user-select: all; padding: var(--s2) 0; }
.ca.empty { color: #D8C79C; }
.plate-links { display: flex; gap: var(--s3); flex-wrap: wrap; }
.key.mark { padding: 0 20px; gap: 10px; }
.key.mark img { width: 26px; height: 26px; }
.key.mark span { font: 600 var(--t-body)/1 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---- the wide band -------------------------------------------------------- */
.band { margin-top: var(--s8); }
.band .bar { background: var(--field); color: var(--ivory); }
.tape { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: var(--t-body); background: var(--field); }
.tape th { text-align: left; font: 600 var(--t-body)/1.2 Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; color: var(--signal); padding: var(--s4) var(--s5); }
.tape td { padding: var(--s4) var(--s5); font-family: Departure, monospace; font-size: var(--t-body); color: var(--ivory); position: relative; }
.tape tbody tr td::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--brass-dim); opacity: .45; }
.tape td.e { color: var(--muted); }
.tape th, .tape td { overflow-wrap: anywhere; }
.wide-p { max-width: 70ch; font-size: var(--t-body); color: var(--ivory); background: var(--field); padding: var(--s5) var(--s6); margin: 0; }
.three, .two { display: grid; gap: var(--s4); align-items: stretch; }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three > div, .two > div { background: var(--field); padding: var(--s5) var(--s6); }
.three h3, .two h3 { margin: 0 0 var(--s2); font: 400 var(--t-body)/1.2 Departure, monospace; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brass); }
.two > div > h3 + p { margin-bottom: var(--s5); }
.two > div > h3 ~ h3 { margin-top: 0; }
.three p, .two p { font-size: var(--t-body); color: var(--ivory); margin: 0; line-height: 1.55; }

/* ---- the toast ------------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%) translateY(16px);
  background: var(--field); color: var(--signal); padding: var(--s4) var(--s5);
  font: 600 var(--t-body)/1.3 Oswald, sans-serif; letter-spacing: 0.04em;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 30; max-width: 90vw;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- widths --------------------------------------------------------------- */
/* Between these widths the sheet still lies beside the map, just narrower, because the order coming in
   on the right IS the mechanic. Under 1100 there is no honest way to keep both, so the sheet goes under
   the map and the map takes the width. */
@media (max-width: 1699px) {
  :root { --card: 400px; --rail: 80px; }
  .index { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ix:nth-child(4) { grid-column: span 2; }
}
@media (max-width: 1099px) {
  :root { --card: 100%; }
  .table { flex-wrap: wrap; }
  .card { flex: 1 1 100%; order: 4; align-self: stretch; }
  .card-body { padding-left: var(--s6); padding-right: var(--s6); min-height: 0; }
  .card-body .bar { margin-left: calc(var(--s6) * -1); margin-right: calc(var(--s6) * -1); }
  .mapwrap { flex: 1 1 auto; }
}
@media (max-width: 700px) {
  .tape th:nth-child(5), .tape td:nth-child(5) { display: none; }
  .index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ix:last-child { grid-column: span 2; }
  .ix { padding: var(--s3) var(--s4); }
}
@media (max-width: 860px) {
  :root { --page: calc(100vw - 32px); --rail: auto; }
  .masthead { flex-wrap: wrap; gap: var(--s3) var(--s4); }
  .wordmark { height: 56px; }
  .markbox { padding: 8px var(--s3); }
  .masthead { gap: var(--s2); padding: var(--s2) var(--s2) calc(var(--s2) + 18px); padding-left: calc(50vw - 50% + var(--s2)); padding-right: calc(50vw - 50% + var(--s2)); }
  .pageno { padding: 16px var(--s5); }
  .standings div { padding: 13px var(--s5); }
  .standings { margin-left: 0; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
  .standings div { text-align: left; min-width: 0; }
  .standings dd { font-size: var(--t-value); }
  .table { flex-wrap: wrap; }
  .rail { width: calc(50% - var(--s2)); flex: 0 0 calc(50% - var(--s2)); padding: var(--s4); }
  .rail-bar { height: 28px; min-height: 28px; width: 100%; flex: 0 0 auto; }
  .mapwrap { flex: 1 1 100%; order: 3; width: 100%; }
  .card { order: 4; }
  .three, .two { grid-template-columns: minmax(0, 1fr); }
  .plate { padding: var(--s5); }
  .teletype { flex-wrap: wrap; }
  .tt-label { width: 100%; min-height: 48px; }
  .tt-line { white-space: normal; }
}
@media (max-width: 420px) {
  :root { --page: calc(100vw - 24px); }
  .card-body { padding-left: var(--s5); padding-right: var(--s5); }
  .card-body .bar { margin-left: calc(var(--s5) * -1); margin-right: calc(var(--s5) * -1); }
  .plate-links { width: 100%; }
  .plate-links .key.mark { flex: 1 1 calc(50% - var(--s3)); padding: 0 var(--s4); }
  .tape th, .tape td { padding: var(--s3) var(--s4); }
  .tape th:nth-child(5), .tape td:nth-child(5) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
