/* =========================================================================
   instrument.css · the frame the simulation sits in

   WHAT THIS IS TRYING TO LOOK LIKE

   A piece of laboratory software on a bench, next to something that cost
   forty thousand pounds. Not a film prop. So: no glow, no grid backgrounds
   pretending to be technical, no scanning lines, no chrome, no glass, no
   typography that has been to space.

   What is left is what actually makes that kind of software read as
   serious. Numbers set in a mono face with tabular figures so a digit
   changing does not move the one next to it. Units in a lighter weight than
   the value they belong to. Hairlines rather than borders. Bracket corners
   at the edge of a viewport, which is a real convention and costs four
   pseudo elements. One accent doing every job that needs an accent, and a
   second colour only where the physics genuinely has two states.

   WHY IT IS NO LONGER DARK

   It was three near blacks, on the argument that a dark bench beside a
   paper notebook made the contrast between the two the point of the site.
   Two things were wrong with that.

   The first is that it made the site two products. A visitor crossing from
   the notebook to a simulation was not moving between rooms, they were
   arriving somewhere else.

   The second is worse and is measurable. Only one of the eight simulations
   ever read the six --lab-* values below. The other seven carried the
   notebook's ink, #332E5C, as a constant in their own files and drew it
   onto a #0d0e11 bench through a transparent canvas. That is about 1.7:1.
   The free energy curve in the nucleation simulation, which is the whole
   argument of the nucleation simulation, was a dark blue line on a near
   black rectangle, and it had been for as long as the frame existed.

   So the bench is light, the tokens are the site's, and the drawing code
   reads them through palette.js rather than guessing. Dark is still here,
   as a theme rather than as a place, and every one of the eight follows it.

   WHAT THE NAMES MEAN NOW

   The five surface and text variables below are kept as names because two
   thousand lines of this stylesheet use them. Each is a mapping onto a
   token, so there is still exactly one place a colour is decided.
   ========================================================================= */

:root {
  /* --surface is deliberately absent: tokens.css already means by it
     exactly what this file means by it, and a custom property that names
     itself on the right hand side is invalid rather than clever. */
  --bg:        var(--paper);        /* the bench */
  --raised:    var(--paper-deep);   /* a control on the panel */
  --hair:      var(--rule-soft);    /* hairline */
  --hair-lit:  var(--rule);

  --text:      var(--ink);
  --text-dim:  var(--ink-soft);
  --text-far:  var(--ink-far);

  --accent:    var(--brand);        /* the one accent */
  --accent-dim:var(--brand-wash);
  --cool:      var(--lavender-ink); /* the other state, and only that */
}

body.inst {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--f-body);
  padding-bottom: 5.5rem;   /* clear of the sound toggle and the levels panel */
}

.mono, .inst .mono {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--text);
  padding: 0.7rem 1rem; z-index: 100;
}
.skip:focus { left: 0; }

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


/* ----------------------------------------------------------------------
   THE HEAD

   The run identifier is a real timestamp, written once when the page comes
   up, because a run identifier that is decorative is worse than none.
   ---------------------------------------------------------------------- */
.inst-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 1.05rem 1.1rem 0.9rem;
  border-bottom: 1px solid var(--hair);
  background: linear-gradient(var(--surface), var(--surface)) padding-box;
}

.inst-ident h1 {
  margin: 0;
  font: 400 15px/1.3 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text);
}

.inst-run {
  margin: 0.32rem 0 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-far);
}

.inst-head-acts { display: flex; gap: 0.5rem; }

.inst-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 0.95rem;
  background: var(--raised);
  color: var(--text-dim);
  border: 1px solid var(--hair-lit);
  border-radius: 2px;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}
.inst-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.inst-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); }
.inst-btn-quiet { background: transparent; }
.inst-btn-go { color: var(--text); border-color: var(--accent-dim); }


/* ----------------------------------------------------------------------
   THE STAGE, AND THE FOUR STEPS OF DISCLOSURE

   0  the question, and nothing else
   1  the crystal, and gravity. one control
   2  the readout, once gravity has actually moved
   3  the other three views, the chrome, the marks and the handoff

   Everything jumps straight to 3. It is on the first screen and it is
   never the default.
   ---------------------------------------------------------------------- */
.inst-stage {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.1rem;
}

.inst-body { display: none; }
body.inst[data-stage="0"] .inst-open { display: block; }
body.inst:not([data-stage="0"]) .inst-open { display: none; }
body.inst:not([data-stage="0"]) .inst-body { display: block; }

body.inst[data-stage="1"] [data-panel="extra"],
body.inst[data-stage="1"] [data-part="readout"],
body.inst[data-stage="1"] [data-part="marks"],
body.inst[data-stage="1"] [data-part="handoff"],
body.inst[data-stage="1"] [data-part="chrome"],
body.inst[data-stage="1"] [data-part="prose"],
body.inst[data-stage="1"] [data-part="late-control"],
body.inst[data-stage="2"] [data-panel="extra"],
body.inst[data-stage="2"] [data-part="marks"],
body.inst[data-stage="2"] [data-part="handoff"],
body.inst[data-stage="2"] [data-part="chrome"],
body.inst[data-stage="2"] [data-part="prose"],
body.inst[data-stage="2"] [data-part="late-control"] { display: none; }


/* ----------------------------------------------------------------------
   THE QUESTION
   ---------------------------------------------------------------------- */
.inst-open {
  max-width: 44rem;
  margin: 2.4rem auto 0;
}

.predict {
  border: 1px solid var(--hair);
  border-left: 2px solid var(--accent-dim);
  background: var(--surface);
  padding: 1.1rem 1.15rem;
}

.predict-q { margin: 0 0 0.9rem; font-size: 1.02rem; }

.predict-opts { display: grid; gap: 0.45rem; }

.predict-opts button {
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  text-align: left;
  background: var(--raised);
  color: var(--text-dim);
  border: 1px solid var(--hair-lit);
  border-radius: 2px;
  font: 400 14px/1.4 "Source Serif 4", Georgia, serif;
  cursor: pointer;
}
.predict-opts button:hover { color: var(--text); }
.predict-opts button.is-chosen { color: var(--text); border-color: var(--accent-dim); }

.predict-result {
  margin: 0.9rem 0 0;
  padding-left: 0.8rem;
  border-left: 2px solid var(--hair-lit);
  color: var(--text-dim);
}
.predict-result.is-right { border-left-color: var(--cool); }
.predict-result.is-wrong { border-left-color: var(--accent); }

.inst-open-note { margin: 1.1rem 0 0; color: var(--text-dim); font-size: 0.95rem; }
.inst-open-note b { color: var(--text); font-weight: 400; }
.inst-open-do { margin: 1rem 0 0; }


/* ----------------------------------------------------------------------
   THE LAB

   Views on the left, the side column on the right, and on a phone the side
   column goes underneath and the views stack. Designed at 320 first rather
   than shrunk onto it.
   ---------------------------------------------------------------------- */
/* minmax(0, 1fr) rather than 1fr, on every one of these. A bare 1fr has an
   automatic minimum, which is the min-content of what is inside it, and a
   canvas carries a 300 px intrinsic width in its own attributes. At 320 that
   pushed the views three pixels off the screen. */
.lab {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
  .lab { grid-template-columns: minmax(0, 1.45fr) minmax(19rem, 0.85fr); align-items: start; }
}

.lab-views { display: grid; gap: 0.7rem; grid-template-columns: minmax(0, 1fr); }

@media (min-width: 560px) {
  .lab-views { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

body.inst[data-stage="1"] .lab-views,
body.inst[data-stage="2"] .lab-views { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 560px) {
  body.inst[data-stage="1"] .lab-views,
  body.inst[data-stage="2"] .lab-views { grid-template-columns: minmax(0, 26rem); }
}

.lab-view {
  position: relative;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--hair);
  padding: 1.55rem 0.7rem 0.7rem;
}

/* Bracket corners. Two pseudo elements on the panel and two on a span
   inside it, which is four corners for one extra element. */
.lab-view::before, .lab-view::after,
.lab-view .brackets::before, .lab-view .brackets::after {
  content: "";
  position: absolute;
  width: 11px; height: 11px;
  border: 0 solid var(--hair-lit);
  pointer-events: none;
}
.lab-view::before { top: 6px; left: 6px; border-top-width: 1px; border-left-width: 1px; }
.lab-view::after { bottom: 6px; right: 6px; border-bottom-width: 1px; border-right-width: 1px; }
.lab-view .brackets::before { top: 6px; right: 6px; border-top-width: 1px; border-right-width: 1px; }
.lab-view .brackets::after { bottom: 6px; left: 6px; border-bottom-width: 1px; border-left-width: 1px; }

.view-tag {
  position: absolute;
  top: 0.5rem; left: 0.85rem;
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.13em;
  color: var(--text-far);
}

/* The canvas is transparent and the panel behind it is the plot surface, so
   the drawing code has to be told which surface it is drawing onto. Without
   this it would knock text out against --paper and the panel is --surface. */
.lab-view { --lab-paper: var(--surface-rgb); }

.lab-view canvas {
  display: block;
  width: 100%;
  height: 240px;
  background: transparent;
}

@media (max-width: 400px) { .lab-view canvas { height: 200px; } }


/* ----------------------------------------------------------------------
   THE ONE PANEL THAT IS STILL DARK

   The thin film simulation draws a real spectrum, and a spectrum argued
   with by a cream background is not the spectrum. So its housing keeps a
   dark plot surface in both themes, and declares its own six rather than
   the drawing code deciding for itself what its housing looks like. This is
   the "scientifically meaningful colour inside a visualisation" case, and
   it is the only one on the site.
   ---------------------------------------------------------------------- */
.lab.is-instrument,
.inst .lab[data-lab="thinfilm"] {
  --lab-paper:  22,  21,  28;
  --lab-ink:   241, 239, 245;
  --lab-sage:  169, 149, 232;
  --lab-corr:  217, 139, 203;
  --lab-rule:   74,  71,  87;
  --lab-soft:  185, 180, 196;
}
.inst .lab[data-lab="thinfilm"] .lab-view {
  --lab-paper: 22, 21, 28;
  background: #16151C;
  border-color: #33303F;
}
.inst .lab[data-lab="thinfilm"] .lab-view .view-tag { color: #B9B4C4; }


/* ----------------------------------------------------------------------
   THE SIDE COLUMN
   ---------------------------------------------------------------------- */
.inst-side {
  display: grid;
  gap: 0.85rem;
  align-content: start;
  /* the same automatic minimum again: a slider with a stepper beside it has
     a min-content wider than a phone */
  grid-template-columns: minmax(0, 1fr);
}

.lab-controls,
.lab-readout,
.inst-marks,
.inst-handoff,
.inst-takes {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--hair);
  padding: 0.9rem 0.95rem;
}

.lab-controls label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.11em;
  color: var(--text-dim);
}
.lab-controls label b {
  color: var(--accent);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 0;
  margin: 0 0.15rem 0 0.35rem;
}

/* The stepper drops under the slider rather than off the side of a phone.
   Both stay 44 px either way. */
.slider-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.55rem 0 0.3rem;
}
.slider-row input[type="range"] { flex: 1 1 8rem; }

.slider-row input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  background: transparent;
  accent-color: var(--accent);
}

.stepper { display: inline-flex; gap: 0.3rem; flex: 0 0 auto; }
.stepper button {
  min-width: 44px; min-height: 44px;
  background: var(--raised);
  color: var(--text-dim);
  border: 1px solid var(--hair-lit);
  border-radius: 2px;
  font: 400 15px/1 "IBM Plex Mono", ui-monospace, monospace;
  cursor: pointer;
}
.stepper button:hover { color: var(--text); }

.quiet { font-size: 10px; letter-spacing: 0.05em; color: var(--text-far); margin: 0; }

.inst-late { margin: 0.75rem 0 0; }

/* Every button inside a simulation, not only the ones with an action
   attribute. The lattice chooser, the acid and indicator buttons and the
   listen control are all buttons a thumb has to hit, and on the notebook
   they were sized by a stylesheet this frame does not load. */
.lab-controls button,
.lab button,
.listen-btn {
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  background: var(--raised);
  color: var(--text-dim);
  border: 1px solid var(--hair-lit);
  border-radius: 2px;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
}
.lab-controls button:hover,
.lab button:hover,
.listen-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.lab-controls button[aria-pressed="true"],
.lab button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); }
.listen-what { margin: 0.5rem 0 0; font-size: 0.86rem; line-height: 1.5; color: var(--text-far); }


/* ----------------------------------------------------------------------
   THE READOUT

   Right aligned on the value, units in a lighter weight than the number,
   tabular figures throughout so nothing shuffles as it counts.
   ---------------------------------------------------------------------- */
.readout-line {
  display: grid;
  grid-template-columns: 1fr auto 2.6rem;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.42rem;
  padding-bottom: 0.42rem;
  border-bottom: 1px solid var(--hair);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-far);
}
.readout-line:last-of-type { margin-bottom: 0; }
.readout-line b {
  justify-self: end;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0;
  color: var(--text);
}

/* The moment a mark sounds, the line it belongs to says so. Heard and seen
   in the same frame, which is the rule. */
.readout-line.is-marked b { color: var(--accent); }
.readout-line.is-marked { border-bottom-color: var(--accent-dim); }

.verdict {
  margin: 0.85rem 0 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--accent);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-dim);
}
.verdict.is-diffusive { border-left-color: var(--cool); }


/* ----------------------------------------------------------------------
   MARKS
   ---------------------------------------------------------------------- */
/* The Takes panel was missing from this list, so on any instrument that
   receives a result from another one its heading fell back to a browser
   default h2 and sat three times the size of the two beside it. */
.inst-marks h2, .inst-handoff h2, .inst-takes h2 {
  margin: 0 0 0.7rem;
  font: 400 10px/1 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-far);
}

.inst-marks ol { margin: 0; padding: 0; list-style: none; }

.inst-marks li {
  display: grid;
  grid-template-columns: 5.6rem 1fr;
  gap: 0.55rem;
  padding: 0.34rem 0;
  border-bottom: 1px solid var(--hair);
  font-size: 11px;
  color: var(--text-dim);
}
.inst-marks li:last-child { border-bottom: 0; }
.inst-marks li time { color: var(--text-far); }
.inst-marks li b { color: var(--accent); font-weight: 500; }
.inst-marks li.is-cool b { color: var(--cool); }
.inst-marks li span { display: block; color: var(--text-far); margin-top: 0.14rem; }

.inst-marks-empty { margin: 0; font-size: 11px; line-height: 1.5; color: var(--text-far); }
.inst-marks[data-any="1"] .inst-marks-empty { display: none; }

/* A mark arriving does not slide, flash or pulse. It appears. */
.inst-marks li.is-new { animation: mark-in 260ms ease-out; }
@keyframes mark-in { from { opacity: 0; } to { opacity: 1; } }


/* ----------------------------------------------------------------------
   HANDOFF
   ---------------------------------------------------------------------- */
.inst-handoff-what {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-dim);
}
.inst-handoff p { margin: 0; }
.inst-handoff p + p { margin-top: 0.7rem; }
.inst-handoff-state { font-size: 11px; letter-spacing: 0.06em; color: var(--text-far); }
.inst-handoff-state[data-sent="1"] { color: var(--accent); }
/* the handoff has no readout row, so this is the line that lights */
.inst-handoff-state.is-marked { color: var(--accent); border-left: 2px solid var(--accent); padding-left: 0.55rem; }


/* ----------------------------------------------------------------------
   CHROME: the depth control and the code panel, both built by sim.js
   ---------------------------------------------------------------------- */
.lab-chrome {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.85rem;
}

/* The three depths. This is the strongest educational idea here, so it is
   given the space to look like a decision rather than three buttons.
   The mark is filled or open, so which is in force never rests on colour. */
.depth {
  padding: 0.8rem 0.9rem;
  background: var(--brand-wash);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
}
.depth-q {
  margin: 0 0 0.55rem;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-far);
}
.depth-set {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.depth-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font: 400 11px/1 var(--f-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
}
.depth-mark {
  width: 9px; height: 9px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}
.depth-btn:hover { color: var(--brand); border-color: var(--brand); }
.depth-btn[aria-pressed="true"] {
  color: var(--on-brand);
  background: var(--brand);
  border-color: var(--brand);
}
.depth-btn[aria-pressed="true"] .depth-mark { background: currentColor; }
.depth-say {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

/* ----------------------------------------------------------------------
   CONNECTED RESEARCH

   An instrument at full screen used to end. Now it says what it belongs to
   and where the same question is written down in prose, which is the whole
   difference between a demonstration and a piece of research.
   ---------------------------------------------------------------------- */
.inst-connected {
  margin: clamp(1.6rem, 5vh, 2.8rem) 0 0;
  padding-top: 1.3rem;
  border-top: 1px solid var(--rule);
}
.inst-connected > h2 {
  margin: 0 0 0.9rem;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-far);
}
.inst-connected-list {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.inst-conn {
  display: block;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.inst-conn:hover { border-color: var(--brand); background: var(--brand-wash); }
.inst-conn-kind {
  display: block;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-far);
}
.inst-conn-name {
  display: block;
  margin: 0.3rem 0 0;
  font-size: 1rem;
  line-height: 1.25;
  color: var(--ink);
}
.inst-conn-say {
  display: block;
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* the opening screen's own label */
.inst-open-h {
  margin: 0 0 0.7rem;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}
.inst-open-do {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.showcode {
  background: var(--surface);
  border: 1px solid var(--hair);
  padding: 0.75rem 0.95rem;
}
.showcode > summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.assumptions-title { margin: 0.4rem 0 0.5rem; font-size: 10px; letter-spacing: 0.14em; color: var(--text-far); }
.assumptions { margin: 0 0 0.9rem; padding-left: 1.1rem; color: var(--text-dim); font-size: 0.9rem; }
.assumptions li { margin: 0 0 0.35rem; }
.code {
  margin: 0;
  padding: 0.85rem;
  overflow-x: auto;
  background: var(--bg);
  border: 1px solid var(--hair);
  font: 400 12px/1.6 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--text-dim);
}

.inst-prose {
  background: var(--surface);
  border: 1px solid var(--hair);
  padding: 0.75rem 0.95rem;
  margin-top: 0.85rem;
}
.inst-prose > summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.inst-prose p { color: var(--text-dim); max-width: 62ch; }
.inst-fig { font-size: 10px; letter-spacing: 0.09em; color: var(--text-far); }

.sim-note {
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
  color: var(--text-far);
}

.inst-noscript {
  max-width: 60ch;
  margin: 2rem auto;
  padding: 0 1.1rem;
  color: var(--text-dim);
}

html[data-depth="picture"] .depth-not-picture { display: none; }
html:not([data-depth="maths"]) .depth-only-maths { display: none; }


/* ======================================================================
   THE INDEX

   A real index, which means a list a person can read down rather than a
   grid of cards padded out to fill a row. Nothing here is a tile, nothing
   is boxed, and no row is completed with filler.

   Each entry says three things and stops: what it is called, the one thing
   it lets you find out, and the quantities it computes. Where a simulation
   takes a result from another or hands one on, that is on the entry and in
   its own colour, because that chain is the argument the whole set is
   making and it was invisible until you stumbled into it.
   ====================================================================== */

/* An index is a list, and a list does not want the width of a spreadsheet.
   One column at a proper reading measure, centred, rather than prose set to
   sixty characters with four hundred pixels of nothing beside it. */
.inst-index .inst-stage { max-width: 52rem; }

.ix-lede {
  max-width: 68ch;
  margin: 1.6rem 0 1.4rem;
  color: var(--text-dim);
  font-size: 1.02rem;
  line-height: 1.6;
}

.ix-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--hair);
}
.ix-jump a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 2px;
  color: var(--text-dim);
  text-decoration: none;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ix-jump a:hover { color: var(--text); border-color: var(--accent-dim); }

.ix-group { margin: 2.4rem 0 0; }

.ix-group > h2 {
  margin: 0 0 0.2rem;
  font: 400 11px/1.4 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.16em;
  color: var(--text-far);
}
.ix-group > h2 span {
  color: var(--accent-dim);
  letter-spacing: 0.1em;
  margin-left: 0.6rem;
}

.ix-list { margin: 0; padding: 0; list-style: none; }

.ix-item {
  padding: 1.15rem 0 1.2rem;
  border-top: 1px solid var(--hair);
}

.ix-name {
  margin: 0 0 0.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
}
/* The padding is not decoration. A line of text is about 23 px tall and a
   thumb needs 44, so the rest is bought above and below the underline
   rather than by making the type bigger than it wants to be. */
.ix-name a {
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  font-size: 1.08rem;
  line-height: 1.35;
  border-bottom: 1px solid var(--hair-lit);
  padding: 1rem 0 0.5rem;
}
.ix-name a:hover { border-bottom-color: var(--accent); }

/* The one that is already in the frame says so, once, and quietly. */
.ix-flag {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 2px;
  padding: 0.2rem 0.4rem;
  white-space: nowrap;
}
.ix-flag.is-open { color: var(--text-far); border-color: var(--hair-lit); }

.ix-find {
  margin: 0 0 0.6rem;
  max-width: 70ch;
  color: var(--text-dim);
  line-height: 1.6;
}
.ix-find b { color: var(--text); font-weight: 400; }

/* The quantities, set as they appear on the readout rather than described. */
.ix-quant {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.1em;
}
.ix-quant span {
  padding: 0.22rem 0.45rem;
  border: 1px solid var(--hair);
  border-radius: 2px;
  color: var(--text-far);
  white-space: nowrap;
}

.ix-meta {
  margin: 0.55rem 0 0;
  font-size: 10px;
  letter-spacing: 0.09em;
  color: var(--text-far);
  line-height: 1.7;
}
.ix-meta b { font-weight: 500; letter-spacing: 0.12em; }
.ix-in { color: var(--cool); }
.ix-out { color: var(--accent); }
.ix-sep { padding: 0 0.55rem; color: var(--hair-lit); }


/* ----------------------------------------------------------------------
   THE CHAINS

   Drawn rather than described, because "hands its result to" is a sentence
   and an arrow with the thing that travels written on it is a fact.
   ---------------------------------------------------------------------- */
.ix-chains { border-top: 1px solid var(--hair); padding-top: 1.6rem; }
.ix-chain-note { margin-top: 0.9rem; }

.ix-chain { margin: 1.4rem 0 0; padding: 0; list-style: none; }
.ix-chain > li {
  padding: 1rem 0 0;
  border-top: 1px solid var(--hair);
  margin-top: 1rem;
}
.ix-chain > li:first-child { border-top: 0; margin-top: 0; padding-top: 0; }

.ix-chain-head {
  margin: 0 0 0.7rem;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-far);
}

/* Drawn top to bottom rather than left to right, which is how a signal path
   is drawn on an instrument and, more to the point, is the only arrangement
   that cannot wrap. A chain that wraps is a chain with a link missing: the
   arrow ends one line and the thing it points at begins the next. */
.ix-chain-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  margin: 0 0 0.8rem;
  max-width: 30rem;
}
.ix-chain-row a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--hair-lit);
  border-radius: 2px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}
.ix-chain-row a:hover { border-color: var(--accent-dim); }

/* A hairline with a head on it. No animation: it is a fact, not a motion. */
.ix-arrow {
  flex: 0 0 auto;
  position: relative;
  width: 1px;
  height: 1.5rem;
  margin-left: 1.2rem;
  background: var(--accent-dim);
}
.ix-arrow::after {
  content: "";
  position: absolute;
  left: -3.5px; bottom: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 6px solid var(--accent-dim);
}

/* What actually travels along the arrow, written beside it. */
.ix-carry {
  margin: -1.35rem 0 0 2.1rem;
  font-size: 10px;
  letter-spacing: 0.09em;
  color: var(--accent);
}

.ix-chain-say {
  margin: 0;
  max-width: 70ch;
  color: var(--text-far);
  font-size: 0.95rem;
  line-height: 1.6;
}

.ix-using { border-top: 1px solid var(--hair); padding-top: 1.6rem; }
.ix-using .ix-find { margin-top: 0.9rem; }

.ix-plain {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  padding: 0.85rem 0 0.45rem;
}
.ix-plain:hover { color: var(--text); }

.ix-foot {
  max-width: 52rem;
  margin: 2.6rem auto 0;
  padding: 1.2rem 1.1rem 0;
  border-top: 1px solid var(--hair);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-far);
}

@media (max-width: 420px) {
  .ix-name a { font-size: 1.02rem; }
}


/* ----------------------------------------------------------------------
   THE SOUND TOGGLE, built by sound.js on every page

   It carries no styling of its own, so the instrument gives it some rather
   than pulling in the notebook's stylesheet for one button.
   ---------------------------------------------------------------------- */
.sound-toggle {
  position: fixed;
  left: 0.75rem;
  bottom: 0.75rem;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  background: var(--surface);
  color: var(--text-far);
  border: 1px solid var(--hair-lit);
  border-radius: 2px;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.sound-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); }
.sound-mark {
  width: 7px; height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.sound-toggle[aria-pressed="true"] .sound-mark { background: currentColor; }

.sound-invite { display: none; }


/* ----------------------------------------------------------------------
   COMING UP

   An instrument coming up rather than a modal opening: the surface first,
   then the hairlines, then the numbers settling. Under 700 ms, four small
   steps, nothing sliding in from off screen and nothing bouncing.
   ---------------------------------------------------------------------- */
body.inst[data-boot="1"] .inst-head,
body.inst[data-boot="1"] .inst-stage { opacity: 0; }

body.inst[data-boot="2"] .inst-head { animation: rise 320ms ease-out both; }
body.inst[data-boot="2"] .inst-stage { animation: rise 380ms 90ms ease-out both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* A panel arriving as disclosure advances. Same gesture, smaller. */
.is-arriving { animation: rise 260ms ease-out both; }

@media (prefers-reduced-motion: reduce) {
  body.inst[data-boot="1"] .inst-head,
  body.inst[data-boot="1"] .inst-stage { opacity: 1; }
  body.inst[data-boot="2"] .inst-head,
  body.inst[data-boot="2"] .inst-stage,
  .is-arriving,
  .inst-marks li.is-new { animation: none; }
  * { transition: none !important; }
}
