/*
  The UI typeface, design tokens and base type on :root, and the wordmark, shared by the app
  (style.css) and the site pages (src/site/site.css). index.html's splash copies the font stack and
  some colours; public/favicon.svg copies some colours.
*/

/*
  IBM Plex Sans (OFL, public/fonts/OFL.txt) in the weights the UI uses, served from our own site.
  Each weight comes in two files, Latin and extended Latin (accented letters such as ł, ō, ș); the
  browser fetches a file only once a page shows one of the characters in its unicode-range. The
  ranges are Fontsource's subsets, which the files were cut to. URLs are from the site root, as for
  any file in public/ (see scripts/site-plugin.ts for the site pages).
*/

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-400.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: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-ext-400.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-500.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: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-ext-500.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-600.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: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-ext-600.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  --bg: #15181b;
  --surface: #20252a;
  --surface-raised: #2a3036;
  --border: #353c43;
  --text: #e3e6e8;
  --text-muted: #9aa3ab;
  --surface-hover: #323940;
  --accent: #d9a441;
  --accent-contrast: #1b1712;
  --warning: #ff6b5e;
  --board-green: #56743f;
  /* The minimap's schematic: track, routes a switch has closed, trains, and the view box. */
  --map-track: #aeb6bd;
  --map-closed: #56606a;
  --map-train: #f2f4f5;
  --map-view: #e3e6e8;
  --overlay-bg: rgb(32 37 42 / 92%);
  --overlay-shadow: 0 4px 16px rgb(0 0 0 / 35%);

  /* Sizes shared by every control, so the header, panels and dialogs line up. */
  --control-height: 30px;
  --radius: 6px;
  --radius-sm: 4px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --icon-size: 18px;
  --toolbar-height: 48px;
  --panel-width: 260px;

  /*
    The UI font, and the system fonts it falls back on (also what canvas text uses until the UI
    font is in: src/render/ui-font.ts).
  */
  --font-system: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-ui: 'IBM Plex Sans', var(--font-system);

  color-scheme: dark;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}

/* The name with the descriptor under it (brandHtml in src/site/content.ts), sized by its parent. */
.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-descriptor {
  color: var(--text-muted);
  font-size: 0.72em;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/*
  The site pages' styles (About, Examples, Guide, 404), on top of the app's tokens (src/tokens.css):
  the site plugin joins the two into one stylesheet.
*/
:root {
  font-size: 16px;
  line-height: 1.6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.site {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site a {
  color: var(--accent);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site .site-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: var(--space-4);
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current='page'] {
  color: var(--text);
}

.site-nav a[aria-current='page'] {
  box-shadow: inset 0 -2px var(--accent);
}

.site-main {
  flex: 1;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) 48px;
}

.site-main h1 {
  margin: 24px 0 var(--space-3);
  font-size: 32px;
  line-height: 1.2;
}

.site-main h2 {
  margin: 36px 0 var(--space-2);
  font-size: 22px;
  line-height: 1.3;
}

.site-main h3 {
  margin: 24px 0 var(--space-1);
  font-size: 17px;
}

.lead {
  color: var(--text-muted);
  font-size: 18px;
}

.site .button {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  text-decoration: none;
}

.site .button:hover {
  filter: brightness(1.1);
}

.site img {
  max-width: 100%;
  height: auto;
}

.shot {
  display: block;
  margin: var(--space-4) 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
  padding: 0;
  list-style: none;
}

.card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card img {
  display: block;
}

.card h2,
.card p {
  margin: var(--space-3) var(--space-3) 0;
}

.card p {
  margin-bottom: var(--space-3);
  color: var(--text-muted);
}

.card h2 {
  font-size: 19px;
}

.topic-list {
  padding: 0;
  list-style: none;
}

.topic-list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.topic-list a {
  font-size: 18px;
  font-weight: 600;
}

.topic-list p {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
}

.crumbs {
  margin-top: var(--space-4);
  color: var(--text-muted);
  font-size: 14px;
}

.toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.tip {
  margin: var(--space-3) 0;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.tip.is-warn {
  border-left-color: var(--warning);
}

.more {
  margin: var(--space-3) 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.more summary {
  color: var(--text-muted);
  cursor: pointer;
}

.keys {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-4);
}

.keys dt {
  font-weight: 600;
}

.keys dd {
  margin: 0;
}

kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font: inherit;
  font-size: 0.85em;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: 48px;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.site-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.site-footer p {
  margin: var(--space-2) 0;
}
