/* The Intercepts demo. Loaded only there, after quantum.css. */

/* ----------------------------------------------------------- intercepts --- */

.ix-intro {
  margin-top: 0.5rem;
}

.ix-part {
  margin-top: 2.5rem;
  font-family: var(--font-serif);
  font-size: 1.625rem;
  font-weight: 400;
  line-height: 1.2;
}

#ix-progress + .ix-part {
  margin-top: 1rem;
}

/* The script fills the lists after the first paint. Each list holds its space
   until then, so the page does not jump. --count is its number of messages,
   and --rows, on a wide screen, the rows that they fill. */
#ix-progress {
  min-height: 1.6em;
}

#ix-list {
  --count: 13;
  --rows: 7;
}

#ix-list2 {
  --count: 7;
  --rows: 4;
}

.ix-list {
  margin-top: 1.5rem;
  min-height: calc(var(--count) * 4rem);
  list-style: none;
  border-top: 1px solid var(--ink-200);
}

.ix-item {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 3.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--ink-200);
  color: var(--ink-950);
  text-decoration: none;
}

a.ix-item:hover .ix-item__name {
  color: var(--spruce);
}

.ix-item__num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-500);
}

.ix-item__name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.25;
}

.ix-item__tool {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ink-600);
}

.ix-item__status {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.ix-item.is-solved .ix-item__status {
  color: var(--spruce);
}

.ix-item.is-next .ix-item__status {
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--spruce);
  color: var(--paper);
}

.ix-item.is-locked {
  color: var(--ink-500);
}

.ix-item.is-locked .ix-item__tool,
.ix-item.is-locked .ix-item__status {
  color: var(--ink-500);
}

.ix-reset {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

#ix-confirm {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
}

.ix-reset .btn,
.ix-reading .btn,
.ix-answer .btn,
.ix-panel .btn,
.ix-solved .btn {
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
}

.ix-reset .btn,
.ix-reading .btn,
.ix-panel .btn {
  padding: 0.75rem 1.1rem;
}

/* One message: the intercept and the reading on one side, the tools on the
   other. */
.ix-msghead {
  display: grid;
  justify-items: start;
  gap: 0.35rem;
}

.ix-back::before {
  content: "← ";
}

.btn.ix-back::before {
  content: none;
}

.ix-work {
  margin-top: 1.5rem;
  display: grid;
  gap: 1.25rem;
}

.ix-side {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

.ix-cipher {
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 1rem 1.25rem;
}

.ix-cipher.is-solved {
  border-left: 4px solid var(--spruce);
}

.ix-ct,
.ix-rt,
.ix-layer__text {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  overflow-y: auto;
}

.ix-ct {
  margin-top: 0.5rem;
  /* Messages in two parts, such as A and B, are on separate lines. */
  white-space: pre-line;
  max-height: 15em;
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--ink-950);
}

.ix-note {
  font-size: 0.9375rem;
  line-height: 1.6;
}

.ix-steps ol {
  margin-top: 0.75rem;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.3rem;
}

.ix-steps li {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-800);
}

.ix-goto {
  padding: 0;
}

.ix-layer {
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem 0 0.5rem 0.9rem;
  border-left: 3px solid var(--ink-400);
}

.ix-layer__text {
  max-height: 7.5em;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--ink-800);
}

.ix-reading {
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  background: var(--white);
  padding: 0.85rem 1rem;
}

.ix-reading__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.ix-rt {
  margin-top: 0.5rem;
  max-height: 12em;
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--ink-950);
}

/* Letters the substitution tool has not placed yet. */
.ix-rt i {
  font-style: normal;
  color: var(--ink-500);
}

.ix-rt b {
  font-weight: 500;
  color: var(--spruce);
}

.ix-answer label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-800);
}

.ix-answer__row {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.5rem;
}

.ix-answer input,
.ix-text {
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border: 1px solid var(--ink-500);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink-950);
  /* 16px or more, so a phone does not zoom in on focus. */
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ix-answer input {
  flex: 1;
  min-width: 0;
}

.ix-text {
  width: 10em;
  max-width: 100%;
}

.ix-answer__msg {
  margin-top: 0.4rem;
  font-size: 0.875rem;
  color: var(--ink-600);
}

/* Not display: none, so a screen reader still sees this live region. */
.ix-answer__msg:empty {
  margin-top: 0;
}

.ix-solved p.ix-solved-more {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-700);
}

.ix-hints {
  display: grid;
  justify-items: start;
}

.ix-hints ol {
  padding-left: 1.25rem;
  display: grid;
  gap: 0.35rem;
}

/* Opened hints sit in their own box, apart from the steps. */
.ix-hints ol:not(:empty) {
  width: 100%;
  margin-top: 0.5rem;
  padding: 1rem 1.25rem 1rem 2.5rem;
  border: 1px solid var(--ink-200);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  background: var(--paper);
}

.ix-hints li {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-700);
}

/* The tools. */
.ix-tools {
  min-width: 0;
}

.ix-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ix-tab {
  min-height: 2.75rem;
  padding: 0 0.9rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink-800);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.ix-tab:hover:not([aria-selected="true"]) {
  background: var(--ink-50);
}

.ix-tab[aria-selected="true"] {
  border-color: var(--spruce);
  background: var(--spruce);
  color: var(--paper);
}

.ix-tab__new {
  margin-left: 0.45rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  vertical-align: 0.1em;
}

.ix-panel {
  margin-top: 1rem;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.ix-panel__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.2;
}

.ix-panel__blurb {
  max-width: 62ch;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-700);
}

.ix-panel__body {
  margin-top: 0.5rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.ix-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ix-row--wrap {
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.ix-lbl {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.ix-step {
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 1.125rem;
  color: var(--ink-950);
  cursor: pointer;
}

.ix-step:hover {
  background: var(--ink-50);
}

.ix-val {
  min-width: 2.2em;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* A readout in words, such as "B under Q". */
.ix-val--words {
  min-width: 6em;
  white-space: nowrap;
  text-align: left;
}

.ix-val--key {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--spruce);
}

.ix-panel input[type="range"] {
  width: min(18rem, 100%);
  min-height: 2.75rem;
  accent-color: var(--spruce);
}

.ix-check {
  min-height: 2.75rem;
  gap: 0.45rem;
  font-size: 0.875rem;
}

.ix-check input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--spruce);
}

.ix-small {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-600);
}

.ix-sub {
  margin-bottom: 0.4rem;
  font-family: var(--font-serif);
  font-size: 1.125rem;
}

.ix-chart {
  display: block;
  width: 100%;
  height: auto;
}

/* Text sizes are in viewBox units. A chart draws at about 0.7 times. */
.ix-chart text {
  font-family: var(--font-mono);
  font-size: 15px;
  fill: var(--ink-600);
}

.ix-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1.25rem;
}

.ix-kas {
  list-style: none;
  max-height: 11em;
  overflow-y: auto;
  display: grid;
  gap: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.ix-kas b {
  font-weight: 500;
  color: var(--spruce);
}

.ix-kas span {
  color: var(--ink-500);
}

/* Caesar wheel */
.ix-wheel-wrap {
  display: grid;
  grid-template-columns: minmax(0, 17rem) minmax(0, 1fr);
  align-items: center;
  gap: 1.25rem;
}

.ix-wheel {
  display: block;
  width: 100%;
  max-width: 17rem;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.ix-wheel text {
  font-family: var(--font-mono);
  font-size: 13px;
  text-anchor: middle;
  dominant-baseline: central;
}

.ix-wheel__outer text {
  fill: var(--ink-950);
  font-weight: 500;
}

.ix-wheel__inner text {
  fill: var(--spruce);
  font-weight: 500;
}

.ix-wheel text.ix-wheel__cap {
  font-family: var(--font-sans);
  fill: var(--ink-500);
}

.ix-wheel text.ix-wheel__shift {
  font-size: 24px;
  fill: var(--ink-950);
}

.ix-stack {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

/* Substitution */
.ix-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.25rem, 1fr));
  gap: 0.4rem;
}

.ix-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.3rem 0 0.4rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-mono);
  cursor: pointer;
}

.ix-tile[aria-pressed="true"] {
  border-color: var(--spruce);
  box-shadow: 0 0 0 2px var(--spruce);
}

.ix-tile.is-over {
  background: var(--ink-50);
}

.ix-tile__c {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink-950);
}

.ix-tile__slot {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 1.85rem;
  border: 1px dashed var(--ink-400);
  border-radius: var(--radius-sm);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--spruce);
}

.ix-tile__slot.is-full {
  border-style: solid;
  border-color: var(--spruce);
  background: var(--paper);
  touch-action: none;
  cursor: grab;
}

.ix-tile__n {
  font-size: 0.75rem;
  color: var(--ink-500);
}

.ix-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ix-pl {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-950);
  touch-action: none;
  cursor: grab;
}

.ix-pl:hover {
  border-color: var(--spruce);
}

.ix-pl.is-used {
  color: var(--ink-500);
  text-decoration: line-through;
}

.is-dragging {
  opacity: 0.35;
}

.ix-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  margin: 0;
  border-color: var(--spruce);
  opacity: 0.95;
  pointer-events: none;
}

/* Vigenère */
.ix-vcols {
  display: grid;
  gap: 0.4rem;
}

.ix-vcol {
  display: grid;
  grid-template-columns: 3.5rem 2.75rem 2rem 2.75rem minmax(4rem, 9rem) minmax(2.5rem, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.ix-vcol canvas {
  display: block;
  width: 100%;
  height: 1.9rem;
}

.ix-meter {
  height: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--ink-100);
  overflow: hidden;
}

.ix-meter span {
  display: block;
  height: 100%;
  background: var(--spruce);
}

/* Keyed alphabet */
.ix-alpha {
  overflow-x: auto;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
}

.ix-alpha table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.ix-alpha th,
.ix-alpha td {
  padding: 0.4rem 0.1rem;
  text-align: center;
}

/* The column where the keyword starts. */
.ix-alpha td.is-start {
  background: var(--ink-100);
  font-weight: 700;
}

.ix-alpha th {
  position: sticky;
  left: 0;
  padding: 0.4rem 0.75rem;
  background: var(--white);
  border-right: 1px solid var(--ink-200);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ink-500);
}

.ix-alpha .is-key td {
  font-weight: 500;
  color: var(--spruce);
}

/* Columns */
.ix-cgrid-wrap {
  overflow-x: auto;
}

.ix-cgrid {
  display: inline-grid;
  gap: 0.2rem 0.25rem;
  font-family: var(--font-mono);
}

.ix-chd {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--spruce);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--spruce);
  touch-action: none;
  cursor: grab;
}

.ix-chd[aria-pressed="true"] {
  background: var(--spruce);
  color: var(--paper);
}

.ix-chd.is-over {
  box-shadow: 0 0 0 2px var(--ink-950);
}

.ix-cc {
  width: 2.25rem;
  text-align: center;
  line-height: 1.6;
}

/* Layers */
.ix-layers {
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.ix-layers li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
}

.ix-layers li.is-top {
  border-left: 4px solid var(--spruce);
}

.ix-layers__num {
  font-family: var(--font-mono);
  color: var(--ink-500);
}

.ix-layers__text {
  display: grid;
  min-width: 0;
  font-size: 0.9375rem;
}

.ix-layers__text .q-mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ix-layers__now {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-500);
}

/* Part 2 */
.ix-qgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.25rem, 1fr));
  gap: 0.35rem;
}

.ix-qcard {
  display: grid;
  justify-items: center;
  gap: 0.05rem;
  padding: 0.3rem 0 0.35rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--ink-800);
  cursor: pointer;
}

.ix-qcard__n {
  font-size: 0.75rem;
  color: var(--ink-500);
}

.ix-qcard__bit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-950);
}

.ix-qcard[aria-pressed="true"] {
  border-color: var(--spruce);
  background: var(--spruce);
  color: var(--paper);
}

.ix-qcard[aria-pressed="true"] .ix-qcard__n,
.ix-qcard[aria-pressed="true"] .ix-qcard__bit {
  color: var(--paper);
}

.ix-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ix-chip {
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink-800);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.ix-chip:hover:not([aria-pressed="true"]) {
  background: var(--ink-50);
}

.ix-chip[aria-pressed="true"] {
  border-color: var(--ink-950);
  background: var(--ink-950);
  color: var(--paper);
}

.ix-mono-block {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.75;
  letter-spacing: 0.06em;
  color: var(--ink-950);
  overflow-wrap: anywhere;
}

.ix-mono-block i,
.ix-recon i {
  font-style: normal;
  color: var(--ink-500);
}

.ix-mono-block b {
  font-weight: 500;
  color: var(--spruce);
}

.ix-text--wide {
  width: 100%;
}

.ix-cands {
  margin-top: 0.4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(9.5rem, 100%), 1fr));
  gap: 0.4rem;
}

.ix-cand {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink-600);
  cursor: pointer;
}

.ix-cand .q-mono {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
  font-size: 0.9375rem;
  color: var(--ink-950);
}

.ix-cand:hover {
  border-color: var(--spruce);
}

.ix-recon {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  background: var(--paper);
}

.ix-blocks {
  display: grid;
  gap: 0.4rem;
}

.ix-block {
  display: grid;
  grid-template-columns: 4.5rem auto auto 1fr;
  align-items: center;
  gap: 0.4rem 0.9rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
}

.ix-block.is-bad {
  border-left: 4px solid var(--ink-950);
}

.ix-block__bits {
  display: flex;
  gap: 0.2rem;
}

.ix-bit {
  width: 2.1rem;
  height: 2.5rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ink-950);
  cursor: pointer;
}

.ix-bit.is-range {
  border-color: var(--ink-950);
  background: var(--ink-50);
}

.ix-block__par {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-600);
  white-space: nowrap;
}

.ix-block__state {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--spruce);
}

.ix-block.is-bad .ix-block__state {
  color: var(--ink-950);
}

.ix-block__act {
  grid-column: 2 / -1;
}

.ix-eqs {
  display: grid;
  gap: 0.25rem;
}

.ix-eq {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0 0.6rem;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  cursor: pointer;
}

.ix-eq input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--spruce);
}

.ix-eq .q-mono {
  font-size: 0.9375rem;
  color: var(--ink-950);
}

.ix-checks,
.ix-glog {
  padding-left: 1.25rem;
  display: grid;
  gap: 0.2rem;
  font-size: 0.875rem;
  color: var(--ink-700);
}

.ix-panel sup {
  font-size: 0.7em;
}

.ix-flash:empty {
  visibility: hidden;
}

.ix-flash {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(var(--q-level-height, 0px) + 1rem);
  z-index: 20;
  width: fit-content;
  margin-inline: auto;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  background: var(--ink-950);
  color: var(--paper);
  font-size: 0.875rem;
  text-align: center;
}

@media (min-width: 48em) {
  /* Filled top to bottom, so the order reads down each column and the
     rows line up across them. The script sets --rows. */

  .ix-list {
    min-height: calc(var(--rows) * 4.25rem);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows, 7), auto);
    grid-auto-flow: column;
    column-gap: 3rem;
    border-top: 0;
  }

  .ix-list > li:first-child .ix-item,
  .ix-list > li.is-coltop .ix-item {
    border-top: 1px solid var(--ink-200);
  }
}

@media (min-width: 56.25em) {
  .ix-work {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: start;
    gap: 2.5rem;
  }

  /* The intercept and the reading stay in view while the tools scroll. */

  .ix-side {
    position: sticky;
    top: 1rem;
    max-height: calc(100svh - var(--q-level-height, 0px) - 2rem);
    overflow-y: auto;
    /* Room for focus rings, which this overflow would clip. */
    margin-inline: -4px;
    padding-inline: 4px;
  }
}

/* On a narrow screen the parts of the side column go around the tools:
   the intercept first, then the tools, then the reading, which sticks to
   the bottom of the screen while the reader works the tools above it. */
@media (max-width: 56.1875em) {
  .ix-work {
    display: flex;
    flex-direction: column;
  }

  .ix-side {
    display: contents;
  }

  .ix-cipher { order: 1; }

  .ix-note { order: 2; }

  .ix-steps { order: 2; }

  .ix-layer { order: 3; }

  .ix-solved { order: 4; }

  .ix-tools { order: 5; }

  .ix-reading { order: 6; }

  .ix-answer { order: 7; }

  /* Just under the note, so a reader who is stuck can find it. */

  .ix-hints { order: 2; }

  /* Two lines of text at most, so the bar leaves room for the tools. */

  .ix-reading {
    position: sticky;
    bottom: var(--q-level-height, 0px);
    z-index: 3;
    margin-inline: calc(-1 * var(--gutter));
    padding: 0.4rem var(--gutter) 0.45rem;
    border-width: 1px 0 0;
    border-radius: 0;
  }

  .ix-work.is-solved .ix-reading {
    position: static;
  }

  .ix-rt {
    max-height: 3.5em;
    margin-top: 0.15rem;
    font-size: 0.875rem;
  }

  /* Over the reading, which sits at the bottom here. */

  .ix-flash {
    top: 1rem;
    bottom: auto;
  }

  .ix-reading .btn {
    padding: 0.45rem 0.75rem;
  }

  /* Keep a focused control clear of the sticky reading below it. */

  #ix-msg-view :is(a,
  button,
  input,
  select,
  [tabindex="0"]) {
    scroll-margin-bottom: 7rem;
  }
}

@media (max-width: 39.9375em) {
  .ix-item {
    gap: 0.75rem;
  }

  .ix-wheel-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .ix-wide-only {
    display: none;
  }

  /* One row of tabs that scrolls sideways, not four rows. */

  .ix-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(-1 * var(--gutter));
    /* The top padding is room for a focus ring, which this overflow would clip. */
    padding: 4px var(--gutter) 0.25rem;
    scrollbar-width: thin;
  }

  .ix-tab {
    flex: none;
  }

  .ix-wheel {
    margin-inline: auto;
    max-width: 15rem;
  }

  /* The panel drops its frame here, so the letter grids get the full
     width and the cipher letters and plain letters fit on one screen. */

  .ix-panel {
    padding: 1rem 0 0;
    border-width: 1px 0 0;
    border-radius: 0;
  }

  .ix-tiles {
    grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr));
    gap: 0.3rem;
  }

  .ix-tile__slot {
    width: 1.75rem;
    height: 1.6rem;
  }

  .ix-palette {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.3rem;
  }

  .ix-pl {
    width: auto;
  }

  .ix-vcol {
    grid-template-columns: 3rem 2.75rem 1.75rem 2.75rem minmax(0, 1fr);
  }

  .ix-vcol .ix-meter {
    display: none;
  }

  .ix-layers li {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ix-layers li > :last-child {
    grid-column: 1 / -1;
    justify-self: start;
  }

  /* Two rows: the label and the state, then the bits and the parities. */

  .ix-block {
    grid-template-columns: auto 1fr;
    column-gap: 0.5rem;
  }

  .ix-bit {
    width: 1.9rem;
  }

  .ix-block > .ix-lbl { grid-area: 1 / 1; }

  .ix-block__state { grid-area: 1 / 2; justify-self: end; }

  .ix-block__bits { grid-area: 2 / 1; }

  .ix-block__par { grid-area: 2 / 2; justify-self: end; }

  .ix-block__act { grid-area: 3 / 1 / 4 / 3; }
}

/* A 320px screen has no room for the parities beside the bits, or for the count
   on each tile. */
@media (max-width: 23em) {
  .ix-block__par {
    grid-area: 3 / 1 / 4 / 3;
    justify-self: start;
  }

  .ix-block__act {
    grid-area: 4 / 1 / 5 / 3;
  }

  .ix-tile__n {
    display: none;
  }

  .ix-pl {
    height: 2.25rem;
  }
}

/* Shown when a tool moves off the answer after a crack. */
.ix-moved {
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  letter-spacing: 0;
  color: var(--ink-600);
}

/* A finger on the palette must be able to scroll the page, since the palette fills
   most of a phone screen. A tap still places the letter. */
@media (pointer: coarse) {
  .ix-pl {
    touch-action: pan-y;
  }
}

/* Under 20em, nothing is pinned. See the large text part of quantum.css. */
@media (max-width: 19.9375em) {
  .ix-reading {
    position: static;
  }
}

/* On a short screen, the Explain bar stops pinning, so the reading keeps its
   place without taking too much of the height. */
@media (max-height: 44em) {
  html:has(.ix-reading) {
    --q-level-height: 0px;
  }

  body:has(.ix-reading) .q-level {
    position: static;
    min-height: 3.25rem;
  }
}

/* See the forced colors part of quantum.css. */
@media (forced-colors: active) {
  .ix-tab[aria-selected="true"],
  .ix-chip[aria-pressed="true"],
  .ix-chd[aria-pressed="true"],
  .ix-bit.is-range,
  .ix-qcard[aria-pressed="true"],
  .ix-qcard[aria-pressed="true"] .ix-qcard__n,
  .ix-qcard[aria-pressed="true"] .ix-qcard__bit,
  .ix-item.is-next .ix-item__status {
    /* Or the browser puts a Canvas plate behind the text, as dark as the text. */
    forced-color-adjust: none;
    background: Highlight;
    border-color: Highlight;
    color: HighlightText;
  }

  .ix-tile[aria-pressed="true"],
  .ix-chd.is-over {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }

  .ix-meter span {
    background: CanvasText;
  }

  .ix-meter {
    border: 1px solid CanvasText;
  }

  .ix-flash {
    border: 1px solid CanvasText;
  }

  .ix-chart,
  .ix-chart text,
  .ix-wheel,
  .ix-wheel text {
    forced-color-adjust: none;
  }

  .ix-chart,
  .ix-wheel {
    background: var(--white);
  }
}
