/* Shared by every page: fonts, colour tokens, base elements and the few
   components the home page and the story pages have in common.

   Fonts are self-hosted, so rendering text contacts no third party. IBM Plex
   is under the SIL Open Font License; the licence sits beside the files in
   assets/fonts/. */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-400-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: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-400-latin-ext.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: italic;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-400-italic-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: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-500-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: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-500-latin-ext.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-600-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: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-600-latin-ext.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 Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-400-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: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-500-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;
}

/* Every colour on the site is one of these. Nothing below the theme blocks,
   and no page stylesheet, names a colour directly, so a theme is one copy of
   this block and nothing else.

   The chart tokens are the one place a theme does more than pick a colour.
   The project charts are images, rendered by each project's own tooling:
   most on a near-black ground, three on white. A chart drawn for the other
   theme is shown through a filter that flips its lightness and turns the
   hues back round, so red stays red and a dark ground becomes a light one.
   The plate colours are what those two grounds come out as, so the plate
   and the image meet without a seam. */
:root {
  color-scheme: light;
  --bg: #FCFCFD;
  --panel: #F3F4F6;
  --track: #E9EBEE;
  --ink: #0E1116;
  --text: #2A2F37;
  --muted: #5A616B;
  --line: #DADDE2;
  --accent: #1F45E0;
  --on-accent: #FFFFFF;
  --warn: #B4530A;
  --warn-ink: #8A3F06;
  --ok: #17703E;
  --neutral: #7C838D;
  --inverse-bg: #0E1116;
  --inverse-ink: #FCFCFD;
  --inverse-text: #E4E7EB;
  --inverse-muted: #B4BAC3;
  --inverse-line: #5A616B;
  --plate: #FFFFFF;
  --chart-dark-filter: invert(1) hue-rotate(180deg) brightness(1.06);
  --chart-dark-plate: #FBFBF9;
  --chart-light-filter: none;
  --chart-light-plate: #FFFFFF;

  --sans: 'IBM Plex Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
  --gutter: clamp(24px, 5vw, 64px);
  --page: 1200px;
}

/* Dark. assets/theme.js sets data-theme on the root element from the
   visitor's stored choice, or from the system setting when there is none. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1115;
  --panel: #171A20;
  --track: #262A32;
  --ink: #F2F4F7;
  --text: #C9CED6;
  --muted: #9AA1AD;
  --line: #2A2F38;
  --accent: #7C9BFF;
  --on-accent: #0B1020;
  --warn: #F0914A;
  --warn-ink: #F4A869;
  --ok: #4CC38A;
  --neutral: #8A919C;
  --inverse-bg: #171A20;
  --inverse-ink: #F2F4F7;
  --inverse-text: #C9CED6;
  --inverse-muted: #9AA1AD;
  --inverse-line: #3A404B;
  --plate: #FFFFFF;
  --chart-dark-filter: none;
  --chart-dark-plate: #121214;
  --chart-light-filter: invert(0.93) hue-rotate(180deg);
  --chart-light-plate: #121212;
}

/* The same block again for a page running without scripts, which has no
   data-theme at all and should still honour a system set to dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0F1115;
    --panel: #171A20;
    --track: #262A32;
    --ink: #F2F4F7;
    --text: #C9CED6;
    --muted: #9AA1AD;
    --line: #2A2F38;
    --accent: #7C9BFF;
    --on-accent: #0B1020;
    --warn: #F0914A;
    --warn-ink: #F4A869;
    --ok: #4CC38A;
    --neutral: #8A919C;
    --inverse-bg: #171A20;
    --inverse-ink: #F2F4F7;
    --inverse-text: #C9CED6;
    --inverse-muted: #9AA1AD;
    --inverse-line: #3A404B;
    --plate: #FFFFFF;
    --chart-dark-filter: none;
    --chart-dark-plate: #121214;
    --chart-light-filter: invert(0.93) hue-rotate(180deg);
    --chart-light-plate: #121212;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, p, figure, blockquote { margin: 0; }
img { max-width: 100%; height: auto; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 16px; background: var(--ink); color: var(--bg);
  font-size: 15px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.wrap { max-width: calc(var(--page) + 2 * var(--gutter)); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

/* Small capitals in the monospace face: section labels, statuses, captions */
.label {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn, .btn-outline {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px;
  font-family: var(--sans); font-size: 16px; font-weight: 500; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  border: 1px solid var(--ink);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn { background: var(--ink); color: var(--bg); }
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-outline { background: transparent; color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: var(--bg); }

.text-link {
  color: var(--accent); font-weight: 500;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.text-link:hover { color: var(--ink); }

/* The theme switch. One button, two icons, and the stylesheet shows the one
   for the theme a click would move to. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line); cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Moving between pages. Opening a project slides it in from the right and
   going back slides it away again, so the site reads as one document with
   depth and not as fifteen separate pages. assets/theme.js names the
   direction; a browser that cannot do this simply loads the next page. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.28s; animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1); }
html:active-view-transition-type(forward)::view-transition-old(root) { animation-name: page-out-left; }
html:active-view-transition-type(forward)::view-transition-new(root) { animation-name: page-in-right; }
html:active-view-transition-type(back)::view-transition-old(root) { animation-name: page-out-right; }
html:active-view-transition-type(back)::view-transition-new(root) { animation-name: page-in-left; }
@keyframes page-out-left { to { opacity: 0; transform: translateX(-32px); } }
@keyframes page-in-right { from { opacity: 0; transform: translateX(32px); } }
@keyframes page-out-right { to { opacity: 0; transform: translateX(32px); } }
@keyframes page-in-left { from { opacity: 0; transform: translateX(-32px); } }

/* Changing theme. The new theme opens as a circle from the switch that was
   pressed. theme.js sets the three variables and the class for the length of
   the transition. */
:root.theme-reveal::view-transition-old(root) { animation: none; mix-blend-mode: normal; }
:root.theme-reveal::view-transition-new(root) { animation: theme-reveal 0.6s cubic-bezier(0.3, 0, 0.2, 1); mix-blend-mode: normal; }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--reveal-x) var(--reveal-y)); }
  to { clip-path: circle(var(--reveal-r) at var(--reveal-x) var(--reveal-y)); }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* Paper is light whatever the screen was showing. */
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme]) {
    color-scheme: light;
    --bg: #FFFFFF;
    --panel: #F3F4F6;
    --track: #E9EBEE;
    --ink: #0E1116;
    --text: #2A2F37;
    --muted: #5A616B;
    --line: #DADDE2;
    --accent: #1F45E0;
    --on-accent: #FFFFFF;
    --warn: #B4530A;
    --warn-ink: #8A3F06;
    --ok: #17703E;
    --neutral: #7C838D;
    --inverse-bg: #FFFFFF;
    --inverse-ink: #0E1116;
    --inverse-text: #2A2F37;
    --inverse-muted: #5A616B;
    --inverse-line: #DADDE2;
    --chart-dark-filter: invert(1) hue-rotate(180deg) brightness(1.06);
    --chart-dark-plate: #FBFBF9;
    --chart-light-filter: none;
    --chart-light-plate: #FFFFFF;
  }
  .skip-link, .theme-toggle { display: none !important; }
}
