/* Cybertanx's player's guide: a page to read, in the game's dark chrome and amber
   with the Strategy Games page's type, condensed headings over system text at 17
   pixels, in a column 640 pixels wide at most. The colors are styles.css's own. No
   text is under 14 pixels, and a link standing alone is 44 pixels tall. Narrow, each
   row of a table is a card that keeps every heading and value; the units' table is a
   card for each unit, with its pictures, at every width. It prints dark on white.
   Unlike the game's screen, the page scrolls, selects and may be pinched to zoom. */

:root {
  --chrome: #1d2226;
  --panel: #272d32;
  --raise: #323a40;
  --line: #46505a;
  --ink: #eef1ec;
  --quiet: #b3bcc2;
  --amber: #f2b134;
  --on-amber: #1d1a10;
  --link: #8fc3ff;
  --head: "Avenir Next Condensed", "DIN Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --text: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--chrome);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.5;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 28px) max(16px, env(safe-area-inset-left));
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  font-family: var(--head);
  font-weight: 700;
  line-height: 1.1;
  text-wrap: balance;
}

h1 {
  margin: 22px 0 18px;
  font-size: 40px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h2 {
  margin: 40px 0 12px;
  padding-top: 22px;
  border-top: 2px solid var(--line);
  font-size: 30px;
}

h3 {
  margin: 28px 0 8px;
  color: var(--amber);
  font-size: 22px;
}

p,
ul,
ol {
  margin: 0 0 14px;
}

ul,
ol {
  padding-left: 1.4em;
}

li {
  margin: 6px 0;
}

li > ul {
  margin: 6px 0 0;
}

strong {
  font-weight: 700;
}

section {
  scroll-margin-top: calc(env(safe-area-inset-top) + 8px);
}

/* ---------- The ways back to the game, and the contents ---------- */

.way-back {
  display: flex;
  margin: 0;
}

.way-back.foot {
  margin-top: 36px;
  padding-top: 22px;
  border-top: 2px solid var(--line);
}

.play {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 9px;
  background: var(--amber);
  color: var(--on-amber);
  font-weight: 700;
  text-decoration: none;
}

.home-note {
  padding: 12px 14px;
  border: 2px solid var(--amber);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 600;
}

.contents .label {
  margin: 0 0 6px;
  color: var(--quiet);
  font-size: 15px;
  font-weight: 700;
}

.contents ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contents li {
  margin: 0;
}

.contents a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--link);
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
}

@media (min-width: 600px) {
  .contents ol {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Pictures ---------- */

.art {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 24px;
  margin: 18px 0 20px;
}

.art:empty,
.pics:empty {
  display: none;
}

.art svg,
.pics svg {
  display: block;
  height: auto;
}

.art .whole {
  width: 176px;
  border-radius: 14px;
}

.art .counter {
  width: 88px;
}

@media (min-width: 480px) {
  .art .whole {
    width: 224px;
  }

  .art .counter {
    width: 104px;
  }
}

.pics {
  display: flex;
  gap: 6px;
}

/* The isometric view, drawn on a canvas by the game's own renderer. */
.iso-art {
  margin: 18px 0 20px;
}

.iso-art canvas {
  display: block;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 5 / 6;
  margin: 0 auto;
  border-radius: 14px;
  background: #14181b;
}

.pics .drawn {
  width: 72px;
}

.pics .symbol {
  width: 62px;
}

@media (min-width: 480px) {
  .pics .drawn {
    width: 84px;
  }

  .pics .symbol {
    width: 72px;
  }
}

/* ---------- Tables ---------- */

table {
  width: 100%;
  margin: 0 0 16px;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.4;
}

th,
td {
  text-align: left;
  vertical-align: top;
}

/* Each cell's heading, shown above its value wherever a row is a card. */
[data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 2px;
  color: var(--quiet);
  font-family: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
}

/* A card for each unit: its pictures, a cell of their own at the row's end, stand left
   of its name across the top, then its values two to a line, or four where there is
   room, and the counts and notes each on a line of their own. */
.units,
.units tbody,
.units tr,
.units th,
.units td {
  display: block;
}

.units thead {
  display: none;
}

.units tr {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 14px;
  margin: 0 0 12px;
  padding: 12px 14px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.units th,
.units td {
  padding: 0;
  font-weight: 400;
}

.units td {
  flex: 1 1 calc(50% - 7px);
}

.units td.wide {
  flex-basis: 100%;
}

.units td.pics {
  display: flex;
  order: -1;
  flex: none;
  gap: 6px;
  align-self: center;
}

.units td.pics:empty {
  display: none;
}

/* The name fills the rest of the top line, beside the pictures, so the values start a
   line of their own. Its heading is the card's, for the eye: a screen reader hears the
   name alone. */
.units th[scope="row"] {
  flex: 1 1 calc(100% - 154px);
  align-self: flex-end;
  font-family: var(--head);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.units tr:not(:has(.pics svg)) th[scope="row"] {
  flex-basis: 100%;
}

.units th[scope="row"]::before {
  content: attr(data-label);
  content: attr(data-label) / "";
}

@media (min-width: 480px) {
  .units td:not(.wide):not(.pics) {
    flex-basis: calc(25% - 10.5px);
  }

  .units th[scope="row"] {
    flex-basis: calc(100% - 176px);
  }
}

/* The other tables are cards when narrow, and tables when there is room. */
@media (max-width: 599.98px) {
  .cards,
  .cards tbody,
  .cards tr,
  .cards th,
  .cards td {
    display: block;
  }

  .cards thead {
    display: none;
  }

  .cards tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 14px;
    margin: 0 0 12px;
    padding: 12px 14px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
  }

  .cards.ground tr,
  .cards.battles tr {
    grid-template-columns: 1fr 1fr;
  }

  .cards th,
  .cards td {
    padding: 0;
    font-weight: 400;
  }

  .cards .wide,
  .cards th[scope="row"] {
    grid-column: 1 / -1;
  }

  .cards th[scope="row"] {
    font-family: var(--head);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
  }
}

@media (min-width: 600px) {
  .cards [data-label]::before {
    content: none;
  }

  .cards thead th {
    padding: 8px 10px;
    border-bottom: 2px solid var(--amber);
    background: var(--raise);
    color: var(--ink);
    font-weight: 700;
    line-height: 1.25;
  }

  .cards tbody th,
  .cards td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
  }

  .cards tbody th {
    font-weight: 700;
  }

  .cards tbody tr:nth-child(even) {
    background: var(--panel);
  }
}

/* ---------- Print: dark on white ---------- */

@media print {
  :root {
    --chrome: #ffffff;
    --panel: #ffffff;
    --raise: #eeeeee;
    --line: #8a8a8a;
    --ink: #000000;
    --quiet: #333333;
    --amber: #000000;
    --link: #000000;
    color-scheme: light;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .way-back,
  .contents {
    display: none;
  }

  h2 {
    break-after: avoid;
  }

  h3 {
    break-after: avoid;
  }

  tr,
  .art,
  .iso-art {
    break-inside: avoid;
  }
}
