/* The site's look, shared by every page: the landing page, the share page and
   every game. Zinc greys, one cyan accent, monospace for labels and numbers,
   flat panels; colour is for requests and for state. See _doctrine/design.md.

   Loaded first, after theme.js has set the saved theme. A page's own stylesheet
   comes after it and adds only what that page draws, using these tokens.

   Order: tokens (light, dark, the same in both), base, controls, the top bar,
   what floats over a game's picture, the stage panel, the end-of-level card. */

/* ---- tokens: light ---- */

:root {
  color-scheme: light;
  /* surfaces */
  --paper: #fafafa;
  --panel: #ffffff;
  --raised: #ffffff;
  --sunken: #f4f4f5;
  /* text */
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #5f5f68;
  /* lines */
  --line: #e4e4e7;
  --line-strong: #c4c4cc;
  /* the drawing */
  --wire: #83838d;
  --box: #ffffff;
  --box-line: #27272a;
  /* requests and other things that move */
  --read: #2563eb;
  --write: #c2690a;
  --static: #059669;
  --flood: #9333ea;
  /* states: the plain ones fill shapes, the -text ones are for words */
  --ok: #12873b;
  --bad: #dc2626;
  --ok-text: #166534;
  --bad-text: #b91c1c;
  --warn-text: #a8540a;
  --warn: #c27a06;
  /* actions */
  --accent: #0e7490;
  --accent-hover: #155e75;
  --accent-ink: #ffffff;
  --accent-text: #0e7490;
  --focus: #0e7490;
  /* levels */
  --level-beginner: #12873b;
  --level-intermediate: #ea580c;
  --level-expert: #dc2626;
  --level-endless: #4f46e5;
  --level-principal: #4f46e5;
  /* how much of the level colour goes into the play area */
  --tint: 6%;
  --shadow: 0 8px 28px rgba(24, 24, 27, 0.12);
}

/* ---- tokens: dark ----
   The same block appears twice: once for a system set to dark, once for a
   visitor who picked dark. test/page.test.js checks the two stay identical. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --paper: #0a0a0b;
    --panel: #141416;
    --raised: #1c1c1e;
    --sunken: #0f0f11;
    --ink: #e4e4e7;
    --ink-2: #c4c4cc;
    --muted: #a1a1aa;
    --line: #27272a;
    --line-strong: #3f3f46;
    --wire: #6b6b76;
    --box: #1c1c1e;
    --box-line: #d4d4d8;
    --read: #60a5fa;
    --write: #f6a823;
    --static: #34d399;
    --flood: #c084fc;
    --ok: #4ade80;
    --bad: #f87171;
    --ok-text: #4ade80;
    --bad-text: #f87171;
    --warn-text: #f6a823;
    --warn: #f6a823;
    --accent: #06b6d4;
    --accent-hover: #22d3ee;
    --accent-ink: #0a0a0b;
    --accent-text: #22d3ee;
    --focus: #22d3ee;
    --level-beginner: #4ade80;
    --level-intermediate: #fb923c;
    --level-expert: #f87171;
    --level-endless: #818cf8;
    --level-principal: #818cf8;
    --tint: 10%;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #0a0a0b;
  --panel: #141416;
  --raised: #1c1c1e;
  --sunken: #0f0f11;
  --ink: #e4e4e7;
  --ink-2: #c4c4cc;
  --muted: #a1a1aa;
  --line: #27272a;
  --line-strong: #3f3f46;
  --wire: #6b6b76;
  --box: #1c1c1e;
  --box-line: #d4d4d8;
  --read: #60a5fa;
  --write: #f6a823;
  --static: #34d399;
  --flood: #c084fc;
  --ok: #4ade80;
  --bad: #f87171;
  --ok-text: #4ade80;
  --bad-text: #f87171;
  --warn-text: #f6a823;
  --warn: #f6a823;
  --accent: #06b6d4;
  --accent-hover: #22d3ee;
  --accent-ink: #0a0a0b;
  --accent-text: #22d3ee;
  --focus: #22d3ee;
  --level-beginner: #4ade80;
  --level-intermediate: #fb923c;
  --level-expert: #f87171;
  --level-endless: #818cf8;
  --level-principal: #818cf8;
  --tint: 10%;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

/* ---- tokens: Blueprint ----
   The landing and share pages' look (Prashant, 2026-10-17): light graph paper,
   navy ink, one blue for actions, mint and lime for highlights. Pages opt in with
   <html data-look="blueprint">. Light only for now, whatever the theme: a dark
   Blueprint is still to come. It names every token the light theme does, so a
   dark choice saved on a game never leaks in, and adds its own for the paper. */

@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/ibm-plex-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 500;
  font-display: swap;
  src: url('fonts/ibm-plex-sans-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/ibm-plex-sans-600.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 500;
  font-display: swap;
  src: url('fonts/ibm-plex-mono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/ibm-plex-mono-600.woff2') format('woff2');
}

:root[data-look='blueprint'] {
  color-scheme: light;
  --paper: #f4f7fb;
  --panel: #ffffff;
  --raised: #ffffff;
  --sunken: #eef3fa;
  --ink: #14213d;
  --ink-2: #33415f;
  --muted: #4d5b78;
  --line: #d3ddea;
  --line-strong: #9fb2cf;
  --wire: #7c8aa6;
  --box: #ffffff;
  --box-line: #14213d;
  --read: #2563eb;
  --write: #c2690a;
  --static: #059669;
  --flood: #9333ea;
  --ok: #12873b;
  --bad: #dc2626;
  --ok-text: #166534;
  --bad-text: #b91c1c;
  --warn-text: #a8540a;
  --warn: #c27a06;
  --accent: #2453d6;
  --accent-hover: #1b40ab;
  --accent-ink: #ffffff;
  --accent-text: #2453d6;
  --focus: #2453d6;
  --level-beginner: #12873b;
  --level-intermediate: #ea580c;
  --level-expert: #dc2626;
  --level-endless: #4f46e5;
  --level-principal: #4f46e5;
  --tint: 6%;
  --shadow: 0 1px 0 rgba(20, 33, 61, 0.04);
  /* the paper: a 24px grid, a heavier line every 96px, and dashed frames */
  --grid: #e1e8f2;
  --grid-fine: #ebf0f7;
  --dash: #9fb2cf;
  /* highlights: mint marks what is done or right, lime what to look at */
  --mint: #c5ffd6;
  --mint-ink: #0b6b3a;
  --lime: #ecffa3;
  --font-sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  /* square corners: a drawing, not an app */
  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
}

/* ---- tokens: the same in both themes ---- */

html {
  /* No web fonts here: JetBrains Mono and DM Sans are used when the reader has
     them installed, otherwise the system's. Blueprint pages load IBM Plex. */
  --font-sans: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', 'DejaVu Sans Mono', monospace;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  /* a selected or active control: a wash of the accent, not a block of it */
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--raised));
  --accent-line: color-mix(in srgb, var(--accent) 45%, var(--line-strong));

  --level: var(--level-beginner);
}

/* Anything that carries a level takes that level's colour: the page's body
   and each level button. */
[data-level='intermediate'],
.level-intermediate {
  --level: var(--level-intermediate);
}

[data-level='expert'],
.level-expert {
  --level: var(--level-expert);
}

[data-level='endless'],
.level-endless {
  --level: var(--level-endless);
}

[data-level='principal'],
.level-principal {
  --level: var(--level-principal);
}

.level[data-level='beginner'],
.level-beginner {
  --level: var(--level-beginner);
}

/* ---- base ---- */

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

/* every h2 and h3 is a small label above a block */
h2,
h3 {
  font: 600 11px/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h2 {
  margin-bottom: 8px;
}

.note {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

kbd {
  padding: 0 5px;
  font: 11px/1.5 var(--font-mono);
  color: var(--muted);
  background: var(--sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

/* ---- controls ---- */

button {
  padding: 5px 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

button:hover:not(:disabled) {
  border-color: var(--accent-line);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button.primary {
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* a button as wide as its panel, for an action in the side panel */
button.wide {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  text-align: left;
}

/* Level and speed are each one joined control, and so is any other row
   of buttons with the class "joined". A level that is a page of its own, as
   Principal is in Scaling, is a link drawn as one of the buttons. */
.levels,
.joined {
  display: flex;
}

.levels a {
  display: inline-flex;
  align-items: center;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.levels button,
.levels a,
.joined button {
  position: relative;
  margin-left: -1px;
  padding: 5px 9px;
  font: 500 12px/1.4 var(--font-mono);
  color: var(--muted);
  border-radius: 0;
}

.levels button:first-child,
.levels a:first-child,
.joined button:first-child {
  margin-left: 0;
  border-radius: var(--radius) 0 0 var(--radius);
}

.levels button:last-child,
.levels a:last-child,
.joined button:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.levels button:only-child,
.levels a:only-child,
.joined button:only-child {
  border-radius: var(--radius);
}

/* the borders overlap by a pixel, so the one in use is lifted above its neighbours */
.levels button:hover:not(:disabled),
.levels a:hover,
.joined button:hover:not(:disabled) {
  z-index: 1;
  color: var(--ink);
}

.levels button:focus-visible,
.levels a:focus-visible,
.joined button:focus-visible {
  z-index: 2;
}

.joined button.on {
  z-index: 1;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

/* The theme is one button that steps through Auto, Light and Dark. theme.js
   draws its icon: a sun, a moon, or for Auto half of each in a dotted ring. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  padding: 6px 7px;
  color: var(--ink-2);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle svg .fill {
  fill: currentColor;
  stroke: none;
}

/* A level kept for signed-in players (src/locked.js): a small padlock after its
   name, drawn in the text's colour. */
.locked::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 11px;
  margin-left: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 22'%3E%3Cpath d='M5 9V6a5 5 0 0 1 10 0v3' fill='none' stroke='black' stroke-width='2.4'/%3E%3Cpath d='M2 9h16v13H2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 22'%3E%3Cpath d='M5 9V6a5 5 0 0 1 10 0v3' fill='none' stroke='black' stroke-width='2.4'/%3E%3Cpath d='M2 9h16v13H2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Each level shows its own colour as a small square. The one being played is
   washed with it. */
.level::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  background: var(--level);
  border-radius: 1px;
}

.level.on {
  z-index: 1;
  color: var(--ink);
  background: color-mix(in srgb, var(--level) 16%, var(--raised));
  border-color: color-mix(in srgb, var(--level) 55%, var(--line-strong));
  cursor: default;
}

/* ---- top bar ---- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

/* the site's icon, and the way back to the landing page */
.home {
  display: inline-flex;
  border-radius: 50%;
}

.home img {
  display: block;
  transition: transform 0.12s;
}

.home:hover img {
  transform: scale(1.1);
}

.brand .sep {
  font-family: var(--font-mono);
  color: var(--line-strong);
}

.brand strong {
  margin-right: 4px;
  font: 600 14px/1.4 var(--font-mono);
}

/* the numbers; they may wrap onto a second line on a narrow screen */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  row-gap: 4px;
  margin-right: auto;
}

.stats dt {
  font: 500 10.5px/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  font: 600 14px/1.4 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats dd.warn {
  color: var(--bad-text);
}

/* pause, speed, restart, messages, keys, theme: in that order on every page */
.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* The Story button names the chosen story only where the bar has room for it:
   with the name, Agent Harness's bar needs about 1560px; without it, every
   game's fits in 1440 with its widest numbers. The name stays in the button's
   tooltip. Narrower than that, the buttons move onto a second line. */
@media (max-width: 1599px) {
  .top .story-name {
    display: none;
  }
}

/* ---- things that float over the picture ---- */

.toast {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 14px;
  width: max-content;
  max-width: min(520px, 90%);
  padding: 8px 14px;
  font-size: 13.5px;
  color: var(--paper);
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

/* keyboard help */
.keys {
  position: absolute;
  z-index: 10;
  top: 14px;
  right: 12px;
  width: min(380px, calc(100% - 24px));
  max-height: calc(100% - 26px);
  overflow: auto;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.keys dl div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
}

.keys dt {
  white-space: nowrap;
}

.keys dd {
  color: var(--muted);
}

/* the messages that were shown over the picture, newest first, in the same floating panel */
.log ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.log li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.log li span {
  display: block;
  font: 11.5px/1.4 var(--font-mono);
  color: var(--muted);
}

.log p {
  font-size: 13.5px;
}

#log-empty {
  color: var(--muted);
}

/* ---- the stage ---- */

.count {
  font: 600 11px/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.mission h1 {
  margin-top: -6px;
  font: 700 17px/1.3 var(--font-mono);
  letter-spacing: -0.01em;
}

#stage-story {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* what this stage adds: a rule down the left, no box */
.new {
  padding: 1px 0 1px 10px;
  font: 12px/1.5 var(--font-mono);
  color: var(--ink-2);
  border-left: 2px solid var(--ok);
}

.mission .primary {
  width: 100%;
}

.goal {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* how much of a limit is used: ink, and red when it is nearly gone */
.meter {
  height: 6px;
  overflow: hidden;
  background: var(--line);
  border-radius: 3px;
}

.meter div {
  width: 0;
  height: 100%;
  background: var(--ink);
  transition: width 0.2s linear;
}

.meter div.bad {
  background: var(--bad);
}

#meter-label {
  font: 12px/1.5 var(--font-mono);
  color: var(--muted);
}

/* what the stage asks for, ticked off as each is met */
.needs li {
  position: relative;
  padding: 1px 0 1px 20px;
  font-size: 13px;
  color: var(--ink-2);
}

.needs li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 6px;
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--line-strong);
  border-radius: 2px;
}

.needs li.done {
  color: var(--ink);
}

.needs li.done::before {
  background: var(--ok);
  border-color: var(--ok);
}

/* the ring that fills while the stage holds: grey while it waits, green while it counts */
.timer {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.timer svg {
  grid-area: 1 / 1;
  width: 56px;
  height: 56px;
  transform: rotate(-90deg);
}

.timer circle {
  fill: none;
  stroke-width: 6;
}

.timer .track {
  stroke: var(--line);
}

.timer .arc {
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-dasharray: 169.65;
  stroke-dashoffset: 169.65;
  transition: stroke-dashoffset 0.15s linear;
}

.timer.holding .arc,
.timer.done .arc {
  stroke: var(--ok);
}

.timer b {
  grid-area: 1 / 1;
  justify-self: center;
  font: 600 14px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.timer.done b {
  color: var(--ok-text);
}

.timer span {
  grid-area: 1 / 2;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}

/* what is wrong: the same left rule, in red */
.trouble {
  padding: 1px 0 1px 10px;
  font-size: 13px;
  border-left: 2px solid var(--bad);
}

.trouble h2 {
  margin-bottom: 4px;
  color: var(--bad-text);
}

.trouble button {
  margin-top: 8px;
  font-size: 12.5px;
}

#trouble-hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

/* after a stage: what went wrong (the red rule) or what mattered (green), then the answer */
.debrief {
  padding: 1px 0 1px 10px;
  font-size: 13px;
  border-left: 2px solid var(--bad);
}

.debrief.cleared {
  border-left-color: var(--ok);
}

.debrief h2 {
  margin-bottom: 4px;
  color: var(--bad-text);
}

.debrief.cleared h2 {
  color: var(--ok-text);
}

.debrief h3 {
  margin-top: 10px;
}

.debrief li {
  padding: 2px 0;
  line-height: 1.45;
  color: var(--ink-2);
}

/* a fix or a choice, named as its control names it, over what it did */
.debrief li b {
  display: block;
  font: 600 12px/1.45 var(--font-mono);
  color: var(--ink);
}

.debrief button {
  margin-top: 8px;
  font-size: 12.5px;
}

#debrief-result {
  padding: 2px 0;
  font: 12px/1.5 var(--font-mono);
  color: var(--muted);
}

.learned li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  font-size: 13px;
}

.learned li::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--ok);
  border-radius: 1px;
  transform: translateY(-1px);
}

/* Asked once of visitors in Europe before anything is recorded (track.js). */
.consent-ask {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.consent-ask p {
  flex: 1 1 100%;
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

/* ---- the end of a level ---- */

/* The card is centred with auto margins, so one taller than the screen can
   still be scrolled to its top. */
.finale {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  padding: 16px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 620px;
  margin: auto;
  padding: 26px 28px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card h1 {
  font: 700 21px/1.25 var(--font-mono);
  letter-spacing: -0.01em;
}

.card h2 {
  margin: 8px 0 0;
}

.card p,
.card li {
  font-size: 13.5px;
}

.card p {
  color: var(--ink-2);
}

.card li {
  padding: 4px 0;
}

.card li strong {
  display: block;
}

.card li span {
  color: var(--muted);
}

/* After a cleared level: what its roles pay, and one question (src/hook.js). */
.hook {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.hook[hidden] {
  display: none;
}

.hook-see {
  align-self: flex-start;
}

.hook-roles a {
  color: var(--accent-text);
}

.hook-ask {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.card .hook-q {
  color: var(--ink);
  font-weight: 600;
}

.hook-choices {
  flex-wrap: wrap;
  align-self: flex-start;
}

.card .hook-note {
  color: var(--muted);
  font-size: 12px;
}

.hook-ask > button.primary {
  align-self: flex-start;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 560px) {
  .card {
    padding: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }
}

/* ---- the story picker: how every game opens ----
   The game's name, what the player is trying to do, and a sentence on how. Then
   the question, and a card for each story: a drawing, a name and one line, of
   which one is chosen. Then what the marks in the picture mean in that story.
   src/story.js builds it into each game's empty #intro. */

.card.intro {
  gap: 18px;
  max-width: 580px;
}

.intro-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card .intro-head p:last-child {
  color: var(--ink-2);
}

.language-pick {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.language-pick .joined {
  align-self: flex-start;
}

.card .intro-question {
  margin: 0;
}

.card .count {
  font: 600 11px/1.4 var(--font-mono);
  color: var(--accent-text);
}

.stories {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card .stories li {
  display: flex;
  padding: 0;
}

/* the drawing on the left, the name and the line beside it, a radio mark in the corner */
.story {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 14px;
  align-content: center;
  min-height: 78px;
  padding: 14px 34px 14px 16px;
  text-align: left;
}

.story .icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  width: 44px;
  height: 44px;
  overflow: visible;
}

/* the same line work as the components, kept at one weight whatever the size */
.story .icon .box,
.story .icon .detail {
  fill: none;
  stroke-width: 1.6px;
  vector-effect: non-scaling-stroke;
}

.story strong {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  font: 600 14px/1.3 var(--font-mono);
  letter-spacing: -0.01em;
}

.story span {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  font-size: 12.5px;
  line-height: 1.4;
}

.story::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}

.story:hover {
  background: var(--accent-soft);
}

/* the chosen story: the accent on its edge, its drawing and its radio mark */
.story.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.story.on::after {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent-soft);
}

.story.on .icon .box,
.story.on .icon .detail {
  stroke: var(--focus);
}

.story.on .icon .glyph {
  fill: var(--focus);
}

/* what the dots are: one row for each colour */
.dots-mean {
  padding: 12px 16px 10px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card .dots-mean h2 {
  margin: 0 0 6px;
}

/* one grid for all the rows, so the labels share a column as wide as the longest */
.dots-mean dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0 16px;
  align-items: center;
}

.dots-mean dl div {
  display: contents;
}

.dots-mean dt,
.dots-mean dd {
  padding: 4px 0;
}

.dots-mean dt {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 11px/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.dots-mean dd {
  font-size: 13.5px;
  color: var(--ink);
}

.actions.spread {
  align-items: center;
  justify-content: space-between;
}

.card .keys-hint,
.card .touch-note {
  font-size: 12px;
  color: var(--muted);
}

/* a phone or tablet has no keys to press: say where the games play best instead */
.card .touch-note {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .card .keys-hint {
    display: none;
  }

  .card .touch-note {
    display: block;
    flex-basis: 100%;
  }

  .card .actions.spread {
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .stories {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- tooltips: one "?" component, one floating bubble ---- */
.tip {
  display: inline-grid; place-items: center; flex: none; width: 15px; height: 15px; padding: 0; margin-left: 5px; vertical-align: 1px;
  font: 600 9.5px/1 var(--font-mono); letter-spacing: 0; text-transform: none; color: var(--muted);
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 50%;
}

.tip::before {
  content: '?';
}

.tip:hover:not(:disabled),
.tip:focus-visible,
.tip[aria-expanded='true'] {
  color: var(--accent-text);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.sr {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#tooltip {
  position: fixed; z-index: 80; max-width: min(290px, calc(100vw - 16px)); padding: 8px 11px; pointer-events: none;
  font: 12.5px/1.45 var(--font-sans); color: var(--paper); background: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* a finger needs more to land on than a pointer does */
@media (pointer: coarse) {
  .tip {
    width: 22px;
    height: 22px;
  }
}
