/* Halden retro primitives. Requires tokens.css. No border-radius anywhere. */
/* Fonts: self-hosted (design/assets/fonts/, SIL Open Font License), so no other site is asked for them. Each page preloads the
   Latin files it draws first; font-display: block holds the text back for a moment instead of drawing it in a fallback face and
   redrawing it, which is the flash this replaces. The pixel faces, then the story faces (Settings, Story font; play view only). */
/* Pixelify Sans, latin */
@font-face { font-family: 'Pixelify Sans'; font-style: normal; font-weight: 400 700; font-display: block;
  src: url('/design/assets/fonts/pixelify-sans-v3-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; }
/* Pixelify Sans, latin-ext */
@font-face { font-family: 'Pixelify Sans'; font-style: normal; font-weight: 400 700; font-display: block;
  src: url('/design/assets/fonts/pixelify-sans-v3-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; }
/* Pixelify Sans, cyrillic */
@font-face { font-family: 'Pixelify Sans'; font-style: normal; font-weight: 400 700; font-display: block;
  src: url('/design/assets/fonts/pixelify-sans-v3-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
/* Silkscreen, latin */
@font-face { font-family: 'Silkscreen'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/silkscreen-v6-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; }
/* Silkscreen, latin-ext */
@font-face { font-family: 'Silkscreen'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/silkscreen-v6-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; }
/* VT323, latin */
@font-face { font-family: 'VT323'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/vt323-v18-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; }
/* VT323, latin-ext */
@font-face { font-family: 'VT323'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/vt323-v18-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; }
/* VT323, vietnamese */
@font-face { font-family: 'VT323'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/vt323-v18-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
/* Jersey 10, latin */
@font-face { font-family: 'Jersey 10'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/jersey-10-v4-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; }
/* Jersey 10, latin-ext */
@font-face { font-family: 'Jersey 10'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/jersey-10-v4-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; }
/* Literata, latin */
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/literata-v40-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; }
/* Literata, latin-ext */
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/literata-v40-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; }
/* Literata, cyrillic-ext */
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/literata-v40-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
/* Literata, cyrillic */
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/literata-v40-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
/* Literata, greek-ext */
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/literata-v40-greek-ext.woff2') format('woff2');
  unicode-range: U+1F00-1FFF; }
/* Literata, greek */
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/literata-v40-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
/* Literata, vietnamese */
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/literata-v40-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
/* Alegreya, latin */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/alegreya-v41-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; }
/* Alegreya, latin-ext */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/alegreya-v41-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; }
/* Alegreya, cyrillic-ext */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/alegreya-v41-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
/* Alegreya, cyrillic */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/alegreya-v41-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
/* Alegreya, greek-ext */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/alegreya-v41-greek-ext.woff2') format('woff2');
  unicode-range: U+1F00-1FFF; }
/* Alegreya, greek */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/alegreya-v41-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
/* Alegreya, vietnamese */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/alegreya-v41-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
/* Atkinson Hyperlegible Next, latin */
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/atkinson-hyperlegible-next-v7-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; }
/* Atkinson Hyperlegible Next, latin-ext */
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 400; font-display: block;
  src: url('/design/assets/fonts/atkinson-hyperlegible-next-v7-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; }

/* Checkerboard dither for page/section backgrounds */
.dither {
  background-color: var(--ground);
  background-image: repeating-conic-gradient(var(--dither) 0% 25%, var(--ground) 0% 50%);
  background-size: 4px 4px;
}

/* Raised window: dark outline, bevel, hard drop shadow, inner double line */
.win {
  position: relative;
  background: var(--surface);
  border: var(--border) solid var(--px-outline);
  box-shadow: inset 2px 2px 0 var(--bevel-hi), inset -2px -2px 0 var(--bevel-lo), var(--shadow-offset) var(--shadow-offset) 0 var(--shadow);
  outline: 2px solid var(--line);
  outline-offset: -9px;
}
/* Title tab sitting on a window's top border */
.win__tab {
  position: absolute; top: -14px; left: 22px;
  padding: 4px 10px;
  background: var(--accent);
  border: var(--border) solid var(--px-outline);
  box-shadow: inset 2px 2px 0 var(--accent-hi), inset -2px -2px 0 var(--accent-lo);
  font: 11px/1.2 var(--font-label); letter-spacing: 0.06em;
  color: var(--on-accent);
}

/* Sunken field: inputs, readouts, slots, stages */
.sunk {
  background: var(--ground);
  border: var(--border) solid var(--px-outline);
  box-shadow: inset 2px 2px 0 var(--bevel-lo), inset -2px -2px 0 var(--bevel-hi);
}

/* Buttons */
.btn, .btn--primary {
  min-height: 44px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border: var(--border) solid var(--px-outline);
  font: 12px/1 var(--font-label);
  text-decoration: none; cursor: pointer;
}
.btn {
  background: var(--raised); color: var(--text);
  box-shadow: inset 2px 2px 0 var(--bevel-hi), inset -2px -2px 0 var(--bevel-lo), 3px 3px 0 var(--shadow);
}
.btn--primary {
  background: var(--accent); color: var(--on-accent);
  box-shadow: inset 2px 2px 0 var(--accent-hi), inset -2px -2px 0 var(--accent-lo), 3px 3px 0 var(--shadow);
}
.btn:active, .btn--primary:active { transform: translate(3px, 3px); box-shadow: inset 2px 2px 0 var(--bevel-lo); }
.btn:focus-visible, .btn--primary:focus-visible { outline: 2px dashed var(--accent); outline-offset: 3px; }

/* Feedback stamps */
.stamp-success {
  padding: 10px 14px; background: var(--accent); color: var(--on-accent);
  border: var(--border) solid var(--px-outline);
  box-shadow: inset 2px 2px 0 var(--accent-hi), inset -2px -2px 0 var(--accent-lo), 4px 4px 0 var(--shadow);
  font: 12px/1 var(--font-label);
}
.stamp-impossible { padding: 8px 10px; border: 2px dashed var(--dim); color: var(--text); font: 10px/1 var(--font-label); }
.diff-add { font: 21px/1.2 var(--font-terminal); color: var(--accent-text); }
.diff-remove { font: 21px/1.2 var(--font-terminal); color: var(--dim); }

/* Tally's speech bubble (tail is an inline pixel SVG, see the mockups) */
.bubble {
  position: relative; padding: 10px 14px;
  background: var(--raised); color: var(--text);
  border: var(--border) solid var(--px-outline);
  box-shadow: 4px 4px 0 var(--shadow);
  font: 22px/1.15 var(--font-terminal);
}

/* Pixel art: always integer scale */
.pixel { image-rendering: pixelated; shape-rendering: crispEdges; }
/* Tally's dithered glow (tally.js): an oval behind him, coloured by --tally-glow; parchment has none. */
tally-sprite { display: inline-block; position: relative; isolation: isolate; }  /* a box round his art, to centre the glow on */
tally-sprite > .tally-glow { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: -1;
  pointer-events: none; background: var(--tally-glow); -webkit-mask: var(--glow-mask) 0 0 / 100% 100% no-repeat;
  mask: var(--glow-mask) 0 0 / 100% 100% no-repeat; }
:root[data-mode="parchment"] tally-sprite > .tally-glow { display: none; }
/* Optional CRT scanlines overlay (off by default) */
.scanlines { position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(to bottom, var(--scanline) 0 1px, transparent 1px 3px); }

/* The only two ambient motions */
@keyframes blink { 0%, 55% { opacity: 1 } 56%, 100% { opacity: 0 } }
@keyframes bob { 0%, 49% { transform: translateY(0) } 50%, 100% { transform: translateY(-6px) } }
.blink { animation: blink 1.1s steps(1) infinite; }
.bob { animation: bob 1.6s steps(1) infinite; }
@media (prefers-reduced-motion: reduce) { .blink, .bob { animation: none; } }
