/*
 * The two sides: what every page drawn in the front page's style shares.
 *
 * Loaded by the front page and by the games catalogue, from the root, by
 * an absolute path -- the catalogue lives in another tree (/games/) and
 * would otherwise need a copy, and two copies of a palette drift apart
 * the first time one of them is tuned.
 *
 * Nothing here applies until a page opts in with class="sides" on <body>.
 * home.css and every page that has not been redrawn stay exactly as they
 * were.
 *
 * Three things live here and nothing else:
 *   1. the two typefaces, served from this domain (see below);
 *   2. the colours of the two sides, as custom properties;
 *   3. the pieces that look the same wherever they appear: the top
 *      navigation and the rope under a game.
 */

/* ---------- typefaces ----------
 *
 * Oswald for display, Onest for text, both under the SIL Open Font
 * License (fonts/OFL-*.txt). Served from here rather than from Google
 * Fonts: the games work offline, and a typeface on someone else's server
 * is not in either service worker's cache -- with the network off every
 * redrawn page fell back to Arial. It also stops telling a third party
 * about every page view.
 *
 * Both are variable fonts, so one file per script covers every weight
 * used. Latin and Cyrillic only; anything outside the two ranges -- a
 * Vietnamese name, a rare symbol -- falls back to the next family in the
 * stack, which is what a missing subset did on Google's side too.
 */
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url(/fonts/oswald-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url(/fonts/oswald-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/onest-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/onest-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- the two sides ----------
 *
 * Red is the human side and blue the machine side everywhere, and only
 * where the content itself has the two sides in it: a score, a share of
 * games, a match. Prose and plain navigation stay in ink. A colour that
 * turns up on everything stops meaning anything.
 */
.sides {
  --h: #b03a2a;          /* the human bar in home.css */
  --h-ink: #8f2c1f;      /* the same red, dark enough for small text */
  --h-bg: #fbeae5;
  --m: #4a6ea9;          /* the machine bar in home.css */
  --m-ink: #2b4a80;
  --m-bg: #e6ecf7;
  --net: #66cc99;        /* twenty years of this domain */
  --ink: #1f2633;
  --ink-soft: #566070;
  --line: #d9dee8;
  --paper: #f6f8fc;
  --display: "Oswald", "Arial Narrow", Arial, sans-serif;
  --text: "Onest", Arial, Helvetica, sans-serif;

  background: #ffffff;
  color: var(--ink);
  font-family: var(--text);
}
.sides a:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ---------- the top navigation ---------- */

.sides #topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  align-items: baseline;
  /* the language badge lang.js and home.js pin to the top right corner */
  padding-right: 64px;
  margin: 0 0 26px 0;
  font-size: 15px;
  font-weight: 500;
}
.sides #topnav a { color: var(--ink); text-decoration: none; }
.sides #topnav a:hover { text-decoration: underline; }
.sides #topnav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}
.sides #topnav .brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .01em;
  margin-right: 8px;
}
.sides #topnav .gap { flex: 1; }

/* ---------- the rope: the human share of finished expert games ---------- */

.sides .rope { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #e7eaf0; }
.sides .rope i { background: var(--h); }
.sides .rope b { background: var(--m); flex: 1; }
.sides .ropeLab {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  font-size: 13px;
  color: var(--ink-soft);
  min-height: 1.4em;
}
.sides .ropeLab .num { font-size: 12px; }
.sides .ropeLab .hs { color: var(--h-ink); }
.sides .ropeLab .ms { color: var(--m-ink); }

@media (max-width: 760px) {
  /* the badge moves to the bottom corner at this width */
  .sides #topnav { padding-right: 0; gap: 6px 16px; margin-bottom: 18px; }
  .sides #topnav .gap { display: none; }
}

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