/* Styles for the animated figures of this post. Each figure is its own page, embedded in
   the post with an iframe; the post draws the white card around the iframe. */
:root {
  --global-text-color: #000000;
  --global-text-color-light: #828282;
}
html,
body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  overflow: hidden;
}
body {
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
/* Padding is a share of the width (a 744-unit card around the 720-unit viewBox), so the page
   keeps the aspect ratio 744 / (viewBox height + 16) that the iframe is given. */
figure.anim-fig {
  --anim-accent: #c0392b; /* the red of the plotted figures */
  --anim-ink: #333333;
  --anim-muted: #777777;
  position: relative;
  margin: 0;
  padding: calc(100% * 10 / 744) calc(100% * 12 / 744) calc(100% * 6 / 744);
  background: #ffffff;
}
.anim-fig > svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}
.anim-fig > svg text {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  fill: var(--anim-ink);
}
.anim-fig .replay {
  position: absolute;
  top: 7px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--global-text-color-light);
  font: inherit;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}
.anim-fig .replay:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--global-text-color);
}
.anim-fig .replay svg {
  width: 11px;
  height: 11px;
}

/* Plot frame and series */
.anim-fig .axis-line {
  fill: none;
  stroke: var(--anim-ink);
  stroke-width: 1;
}
.anim-fig > svg .title {
  font-size: 16px;
}
.anim-fig > svg .axis-label {
  fill: var(--anim-muted);
}
.anim-fig > svg .tick.on {
  font-weight: 700;
  fill: var(--anim-accent);
}
.anim-fig .series {
  fill: none;
  stroke: var(--anim-accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.anim-fig .dot {
  fill: var(--anim-accent);
}
.anim-fig .dot.on {
  stroke: #ffffff;
  stroke-width: 1.5;
}
/* Values and guides that fade in for the model being shown */
.anim-fig > svg .value {
  font-size: 13px;
  font-weight: 500;
  fill: var(--anim-accent);
  stroke: #ffffff;
  stroke-width: 3px;
  stroke-linejoin: round;
  paint-order: stroke;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.anim-fig > svg .value.on {
  opacity: 1;
}
.anim-fig .guide {
  stroke: #bbbbbb;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.anim-fig .guide.on {
  opacity: 1;
}
.anim-fig .hit {
  fill: transparent;
}

/* The bar above a figure: a grey track for the whole range, filled up to the current value */
.anim-fig .bar-track {
  fill: #e4e4e4;
}
.anim-fig .bar-fill {
  fill: var(--anim-accent);
}
.anim-fig .bar-tick {
  stroke: #b0b0b0;
  stroke-width: 1;
}
.anim-fig > svg .readout {
  font-size: 15px;
}
.anim-fig > svg .readout .num {
  font-weight: 700;
  fill: var(--anim-accent);
}
.anim-fig > svg .readout .note,
.anim-fig > svg .stop,
.anim-fig > svg .stop .note {
  fill: var(--anim-muted);
  font-weight: 400;
}
.anim-fig > svg .stop.on {
  font-weight: 700;
  fill: var(--anim-accent);
}

/* A needle moving away from the query on the bar, and curves against that distance */
.anim-fig .bar-fill.gap {
  fill-opacity: 0.35;
}
.anim-fig .needle {
  fill: var(--anim-accent);
  stroke: #ffffff;
  stroke-width: 2;
}
.anim-fig .query-pin {
  fill: var(--anim-ink);
}
.anim-fig > svg .query-label {
  font-size: 13px;
  font-weight: 500;
}
.anim-fig .beyond {
  fill: #e8e8e8; /* distances beyond the SWA window */
}
.anim-fig .window-line {
  stroke: #111111;
  stroke-width: 1;
  stroke-dasharray: 3 2;
}
.anim-fig .pulse {
  stroke: var(--anim-accent);
}
.anim-fig .series.thin {
  stroke-width: 1.8;
}

/* A line of text that narrates the animation; "hot" lines are in the accent colour */
.anim-fig > svg .message {
  font-size: 15px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.anim-fig > svg .message.on {
  opacity: 1;
  transition-delay: 0.15s; /* the old line leaves before the new one comes in */
}
.anim-fig > svg .message.hot,
.anim-fig > svg .message .hot {
  fill: var(--anim-accent);
}
.anim-fig > svg .message .quiet {
  fill: #8a8a8a;
}

/* Layer-by-head grids: one square per attention head */
.anim-fig .grid-open {
  fill: #ffffff;
}
.anim-fig .grid-band {
  fill: #d9d9d9;
}
.anim-fig .grid-lines {
  fill: none;
  stroke: rgba(0, 0, 0, 0.07);
  stroke-width: 0.5;
}
.anim-fig .grid-frame {
  fill: none;
  stroke: var(--anim-ink);
  stroke-width: 1;
}
.anim-fig .head {
  fill: var(--anim-accent);
}
.anim-fig .ripple {
  fill: none;
  stroke: var(--anim-accent);
  stroke-width: 1.5;
}
.anim-fig > svg .tally {
  font-size: 13px;
  fill: var(--anim-muted);
}
.anim-fig > svg .tally .num {
  font-weight: 700;
  fill: var(--anim-ink);
}
.anim-fig > svg .tally.hot .num {
  fill: var(--anim-accent);
}
.anim-fig > svg .legend text {
  font-size: 13px;
}
.anim-fig .swatch.grid-open {
  stroke: #999999;
  stroke-width: 1;
}

/* Bars per attention head, coloured by the kind of layer the head is in (lighter for random heads) */
.anim-fig .type-none {
  --bar: #4d4d4d;
}
.anim-fig .type-swa {
  --bar: #2b6cb0;
}
.anim-fig .type-nope {
  --bar: #d95f02;
}
.anim-fig .type-swa.random {
  --bar: #a9c4e0;
}
.anim-fig .type-alibi {
  --bar: #6a3d9a;
}
.anim-fig .type-alibi.random {
  --bar: #cab2d6;
}
.anim-fig .type-nope.random {
  --bar: #efc1a3;
}
.anim-fig .bar {
  fill: var(--bar);
}
.anim-fig .bar.ghost {
  fill-opacity: 0.22; /* the part of a bar that was lost */
}
.anim-fig .head-box {
  fill: var(--bar);
  stroke: var(--bar);
  stroke-width: 1;
}
.anim-fig .star {
  fill: #111111; /* a recall head before long-context extension */
}
.anim-fig .baseline {
  stroke: #111111;
  stroke-width: 1;
  stroke-dasharray: 3 2;
}
.anim-fig .bracket {
  fill: none;
  stroke: #999999;
  stroke-width: 1;
}
.anim-fig > svg .title.small {
  font-size: 13px;
}
.anim-fig > svg .tick.small {
  font-size: 11px;
}
.anim-fig > svg .group {
  font-size: 11.5px;
  fill: var(--anim-muted);
}
.anim-fig > svg .head-name {
  font-size: 11px;
}
.anim-fig > svg .head-name.on {
  font-weight: 700;
}
.anim-fig > svg .drop {
  font-size: 10px;
  font-weight: 600;
  fill: var(--anim-accent);
}
