:root {
  color-scheme: light;
  --paper: #fdfdfd;
  --ink: #333;
  --muted: #626262;
  --line: #d3d3d3;
  --blue: #0000ff;
  --measure: 768px;
  --panel-width: 462px;
  --mark-blue: #194fe3;
  --mark-ochre: #b74800;
  --mark-teal: #007e67;
  --mark-plum: #8730cd;
  --mark-rose: #c61f5c;
  --mark-olive: #687700;
  --mark-cyan: #006e8c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 1.5rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.25rem/1.6 Palatino, "Palatino Linotype", "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
}
main { width: min(var(--measure), calc(100% - 32px)); margin-inline: auto; padding-block: 2rem 4rem; }
.prose { width: 100%; margin-inline: 0; }
p { margin: .9rem 0; }
h1 { font-size: clamp(2.7rem, 6vw, 3.5rem); font-weight: normal; line-height: 1.12; letter-spacing: -.035em; margin: 0; }
h2 { font-size: clamp(1.8rem, 4vw, 2.15rem); font-weight: normal; line-height: 1.2; letter-spacing: -.015em; margin: 0 0 1.2rem; }
h3 { font-size: 1.35rem; line-height: 1.35; margin: 2.4rem 0 .7rem; }
h4 { font-size: 1.2rem; line-height: 1.4; margin: 2rem 0 .6rem; }
.section-rule { border: 0; border-top: 1px solid var(--line); margin: 2.4rem 0 1.5rem; }
.section-rule + :is(h1,h2,h3) { margin-top: 0; }
section { margin-top: 5rem; }
article > section:first-child { margin-top: 0; }
a, a:visited { color: var(--blue); text-underline-offset: .13em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.byline { color: var(--muted); margin: 0 0 clamp(1.5rem, 2.5vw, 2rem); }
.byline span { margin-inline: .55rem; color: #888; }
.subtitle { font-size: 1.5rem; line-height: 1.35; margin: .7rem 0 1.8rem; }
.lead { font-size: 1.4rem; line-height: 1.55; }
.skip-link { position: absolute; left: 1rem; top: -5rem; background: var(--paper); padding: .4rem .8rem; z-index: 2; }
.skip-link:focus { top: 1rem; }
body > svg.sr-only { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

figure { min-width: 0; margin: 2.5rem 0; }
figcaption, .figure-note { font-size: 1rem; line-height: 1.5; color: var(--muted); margin-top: .9rem; }
img { display: block; max-width: 100%; height: auto; }
svg { display: block; max-width: 100%; height: auto; }
svg image, .artifact img { image-rendering: pixelated; }
.intro-text { margin-top: 1.5rem; }
.intro-questions { margin: 1.2rem 0 0; }
.intro-questions .section-rule { margin: 1.5rem 0 .7rem; }
.intro-questions h3 { margin: 0 0 .5rem; }
.intro-questions p { margin: .3rem 0 .7rem; }
.artifact { width: 100%; margin-top: 3rem; }
.artifact-image { position: relative; border: 1px solid #aaa; background: white; }
.artifact img { width: 100%; }
.strip-outline { position: absolute; inset: 0 0 auto; width: 100%; height: 3.125%; pointer-events: none; }
.strip-outline { color: var(--mark-blue); }
.annotated { color: var(--mark-blue); }
.annotation-note { font-size: 1rem; color: var(--muted); }
.contents { border-block: 1px solid var(--line); margin-block: 2.5rem; padding: 1.1rem 0 1.3rem; font-size: 1.05rem; }
.contents p { margin: 0 0 .6rem; }
.contents ol { margin: 0; padding-left: 1.5rem; }
.contents li { padding: .2rem 0; }

/* One reading column; each source panel follows its explanation. */
.lesson { display: block; width: 100%; margin: 3.5rem 0; }
.lesson h3 { margin-top: 0; }
.raw-panel { width: 100%; margin: 1.7rem 0 2.5rem; }
.raw-panel > svg:not(.crc-feedback), .visual-key-example > svg { width: var(--panel-width); height: auto; margin-inline: auto; background: white; }
.raw-panel figcaption { margin-top: 1.1rem; }
.key { font-weight: 600; }
.key, .annotated, th[class*="ink-"] { cursor: pointer; }
/* Grow each inline fragment's hit area without changing the reading layout. */
.key, .annotated {
  padding: 5px 4px;
  margin: -5px -4px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
:is(.panel-mark, .logical-cell, .source-bit-grid, .reading-mark, .source-ring, .change-ring, .region-bound, .cell-grid, .strip-outline, svg text, .files, .ranks) {
  transition: opacity 150ms ease;
}
[data-annotation-muted],
[data-annotation-clean] :is(.panel-mark, .logical-cell, .source-bit-grid, .reading-mark, .source-ring, .change-ring, .region-bound, .cell-grid, .strip-outline, text, .files, .ranks) {
  opacity: 0;
}
.ink-blue { color: var(--mark-blue); }
.ink-ochre { color: var(--mark-ochre); }
.ink-teal { color: var(--mark-teal); }
.ink-plum { color: var(--mark-plum); }
.ink-rose { color: var(--mark-rose); }
.ink-olive { color: var(--mark-olive); }
.ink-cyan { color: var(--mark-cyan); }
.panel-mark, .reading-mark, .source-ring, .change-ring, .strip-outline rect {
  fill: currentColor;
  fill-opacity: .2;
  stroke: none;
  stroke-dasharray: none;
  pointer-events: none;
}
.logical-cell { fill: none; stroke: #b7bcc2; stroke-width: .8; vector-effect: non-scaling-stroke; pointer-events: none; }
.source-bit-grid { fill: none; stroke: #92969c; stroke-width: .65; vector-effect: non-scaling-stroke; pointer-events: none; }
.band-reading { margin-block: 1.5rem; }
.band-reading > p { font-size: 1.05rem; }
.band-table { font-size: .95rem; }
.band-table th:first-child { width: 28%; }
.band-table th:nth-child(2) { width: 42%; }
.band-table th:nth-child(3) { width: 22%; }
.band-table th:nth-child(4) { width: 8%; }
.band-bits { display: block; font-size: .82em; line-height: 1.75; overflow-wrap: normal; }
.orientation-example { margin-block: 2.4rem; }
.orientation-example > h3 { margin-top: 0; }
.header-example { margin: 1.7rem 0; }
.header-example p { font-size: 1rem; margin-bottom: .5rem; }
.header-example > svg { width: var(--panel-width); margin-inline: auto; }
.corner-turns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1.6rem 0; }
.corner-turns > div > svg { width: 60px; height: 60px; margin-inline: auto; background: white; }
.corner-turns p { font-size: .9rem; text-align: center; line-height: 1.4; }
.raw-field { margin-block: 2rem; }
.raw-field > svg { width: 100%; height: auto; image-rendering: pixelated; background: white; margin-bottom: 1.3rem; }
.raw-field p { font-size: 1.1rem; }

.table-wrap { width: 100%; min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; line-height: 1.5; text-align: left; margin: 2.5rem 0 1.4rem; }
caption { text-align: left; font-size: 1.05rem; caption-side: top; margin-bottom: .8rem; color: var(--ink); }
th, td { vertical-align: top; padding: .7rem .8rem .7rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { font-weight: normal; }
thead th { border-bottom: 1px solid #777; color: var(--ink); }
tbody th { color: var(--ink); }
td { color: #4b4b4b; }
th:last-child, td:last-child { padding-right: 0; }
code, .mono { font-family: var(--mono); font-size: .82em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.equation { font: .95rem/1.85 var(--mono); overflow-wrap: anywhere; }
.crc-feedback { width: 100%; max-width: 680px; height: auto; margin: 2.5rem auto 0; }
.payload-bits { width: 100%; max-width: 360px; margin-inline: auto; background: white; }
.payload-glyph { width: 100%; max-width: 540px; margin-inline: auto; background: white; }
.payload-example { margin-block: 2rem 3rem; }
.glyph-id-grid { table-layout: fixed; text-align: center; }
.glyph-id-grid th, .glyph-id-grid td { padding: .45rem .1rem; }
.glyph-id-grid tbody th { color: var(--muted); }
.glyph-id-grid [data-selected-cell] { background: rgba(183, 72, 0, .2); font-weight: bold; }
.section-envelope { border: 1px solid #92969c; padding: 1rem; }
.section-label { margin: 0 0 1.2rem; }
.section-flow { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.checksum-input { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.5rem; }
.section-field { min-width: 0; }
.section-field p { font-size: .95rem; }
.section-field > p:first-child { margin-top: 0; }
.section-field svg { width: 160px; margin-inline: auto; background: white; }
.checksum-scope { grid-column: 1 / -1; border-top: 1px solid #777; padding-top: .7rem; font-size: .95rem; }
.checksum-match { font-size: 1.05rem; }
.reference-path { list-style: none; padding: 0; margin: 0; }
.reference-path li { display: grid; justify-items: center; text-align: center; gap: .4rem; font-size: 1rem; }
.reference-path li > code { font-size: 1.25rem; }
.reference-edge { color: var(--muted); padding-block: .4rem 1rem; }

.example { width: 100%; padding: 1.5rem 0 1.7rem; margin-block: 2.7rem; }
.example > figcaption:first-child { color: var(--ink); font-size: 1.2rem; margin: 0 0 1.1rem; }
.example > .figure-note { margin: 1.2rem 0 0; }
.instruction { display: none; font-size: 1.05rem; line-height: 1.55; }
.is-enhanced .instruction { display: block; }
.example:not(.is-enhanced) .position { display: none; }
.position { font: .8rem/1.5 var(--mono); color: var(--mark-blue); margin: 1.2rem 0 .6rem; }
.readout { font-size: 1.05rem; min-height: 3.1em; margin: 1rem 0; overflow-wrap: anywhere; }
.controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
button { font: .9rem/1.3 system-ui, sans-serif; min-height: 44px; padding: .65rem .9rem; border: 1px solid #777; border-radius: 2px; color: var(--ink); background: var(--paper); cursor: pointer; }
button:hover { background: #f0f0f0; border-color: var(--ink); }
button:active { background: #e2e2e2; }
button:disabled { opacity: .4; cursor: default; }
button:disabled:hover { background: var(--paper); }

/* Comparisons share a figure; explanatory prose never sits in a sidebar. */
.two-up, .small-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; align-items: start; }
.three-up, .static-states, .game-layout { display: block; }
.two-up > figure, .small-comparison > figure { margin: 0; }
.three-up > figure, .static-states > figure { margin: 2rem 0; }
.board-svg { width: 100%; max-width: 340px; height: auto; margin-inline: auto; background: white; }
.board-svg .cell-grid { stroke: #bbb; stroke-width: .6; fill: none; }
.board-svg .source-ring { color: var(--mark-blue); }
.board-svg .change-ring { color: var(--mark-ochre); }
.board-svg .change-cleared { color: var(--mark-blue); }
.board-svg .change-assigned { color: var(--mark-ochre); }
.board-svg .change-metadata { color: var(--mark-teal); }
.board-svg .region-bound { stroke: #777; stroke-width: 1; stroke-dasharray: 2 3; fill: none; }
.board-svg use { color: #111; }
.board-svg text { font: 16px var(--mono); fill: var(--ink); }
.coordinate-board { display: grid; grid-template-columns: 1.1rem minmax(0, 1fr); grid-template-rows: auto 1.3rem; width: 100%; max-width: calc(340px + 1.1rem); margin-inline: auto; }
.files { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(8, 1fr); align-items: center; font: .7rem var(--mono); color: var(--muted); text-align: center; }
.ranks { grid-column: 1; grid-row: 1; display: grid; grid-template-rows: repeat(8, 1fr); font: .7rem var(--mono); color: var(--muted); align-items: center; }
.coordinate-board > .board-svg { grid-column: 2; grid-row: 1; }
.two-up figcaption, .three-up figcaption, .small-comparison figcaption, .static-states figcaption { text-align: center; }
.compact .board-svg { max-width: 240px; }
.glyph-samples { display: flex; gap: 2rem; justify-content: center; }
.glyph-samples figure { margin: 0; width: 70px; text-align: center; }
.glyph-samples .board-svg { width: 70px; }
.glyph-definition { display: block; }
.glyph-definition .board-svg { width: 104px; max-width: 100%; }
.piece-pairs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.3rem; }
.piece-pairs figure { margin: 0; text-align: center; }
.piece-pairs .board-svg { max-width: 120px; }
.packing-lesson .two-up { display: block; }
.packing-lesson .two-up > figure { margin: 1.6rem 0; }
.packing-lesson .board-svg { max-width: 100%; }
.physical-word { width: 100%; height: auto; image-rendering: pixelated; border: 1px solid #777; background: white; margin: 1.2rem 0 .5rem; }
.small-comparison { gap: 2rem; margin-block: 2rem; }
.small-comparison.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.small-comparison > figcaption { grid-column: 1/-1; text-align: left; margin: 0; }
.small-comparison .board-svg { max-width: 240px; }
.small-comparison.three .board-svg { max-width: 180px; }
.game-layout { margin: 1.5rem 0; }
.game-layout > div:first-child > figure { margin: 0; }
.game-explanation { margin-top: 1.8rem; }
.game-explanation h3 { margin-top: .6rem; }
.footer-strip { width: min(340px, 100%); margin: 1rem auto 0; }
.footer-strip > span { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .4rem; }
.board-label { text-align: center; font-size: 1rem; color: var(--muted); margin: .6rem 0; }
footer { color: var(--muted); margin-top: 4rem; padding-top: 1.3rem; border-top: 1px solid var(--line); }

.guide-nav { display: none; }
@media (min-width: 1280px) {
  .guide-nav {
    display: block;
    position: fixed;
    top: 2rem;
    bottom: 2rem;
    left: 1.5rem;
    width: calc(50% - var(--measure) / 2 - 3.5rem);
    max-width: 240px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    padding: .25rem .5rem .25rem 0;
    font-size: .85rem;
    line-height: 1.4;
  }
  .guide-nav ol { list-style: none; margin: 0; padding: 0; }
  .guide-nav ol ol { padding-left: .8rem; }
  .guide-nav > ol > li { margin-bottom: .6rem; }
  .guide-nav li[data-level="1"] > a { font-size: .95rem; font-weight: 600; margin-bottom: .5rem; }
  .guide-nav li[data-level="2"] { margin-block: .5rem; }
  .guide-nav li[data-level="2"] > a { font-weight: 600; }
  .guide-nav a {
    display: block;
    border-left: 2px solid transparent;
    padding: .3rem .4rem;
    color: var(--muted);
    text-decoration: none;
    overflow-wrap: anywhere;
  }
  .guide-nav a:hover { color: var(--ink); text-decoration: underline; }
  .guide-nav a[aria-current] { border-left-color: var(--ink); color: var(--ink); font-weight: 600; }
}

@media (max-width: 600px) {
  body { font-size: 1.15rem; }
  main { padding-block: 1.4rem 3rem; }
  section { margin-top: 4rem; }
  .lesson { margin-block: 3rem; }
  .section-flow { grid-template-columns: 1fr; }
  .two-up { display: block; }
  .two-up > figure { margin: 1.6rem 0; }
  .piece-pairs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
  .small-comparison { gap: 1rem; }
  .small-comparison.three { grid-template-columns: 1fr; }
  .small-comparison.three > figure { width: 100%; max-width: 240px; margin: auto; }
  table { font-size: .9rem; }
  th, td { padding: .65rem .5rem .65rem 0; }
  .band-table { display: block; }
  .band-table caption { display: block; width: 100%; }
  .band-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .band-table tbody { display: block; }
  .band-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: .65rem 0; border-bottom: 1px solid var(--line); }
  .band-table th, .band-table td { display: block; width: auto !important; padding: .2rem 0; border: 0; }
  .band-table th, .band-table .bits-cell { grid-column: 1 / -1; }
  .band-table .value-cell::before { content: "Decimal: "; color: var(--muted); }
  .band-table .reading-cell::before { content: "Read as: "; color: var(--muted); }
  .band-table .width-cell::before { content: "Bytes: "; color: var(--muted); }
  .band-table .width-cell { padding-left: 1rem; }
  .corner-turns { gap: .5rem; }
  .corner-turns p { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  :is(.panel-mark, .logical-cell, .source-bit-grid, .reading-mark, .source-ring, .change-ring, .region-bound, .cell-grid, .strip-outline, svg text, .files, .ranks) {
    transition: none;
  }
}
@media print {
  .controls, [data-practice-controls], .instruction, .skip-link, .contents, .guide-nav { display: none !important; }
  body { font-size: 11pt; background: white; }
  main { width: 100%; padding: 0; }
  section { margin-top: 2rem; }
  figure { break-inside: avoid; }
  .raw-panel > svg { width: var(--panel-width); }
  a { color: inherit !important; }
}
