/* Colors keep the roles they have in the paper and poster:
   ink for text and chrome, sand for surfaces, blue for answers given from text alone,
   orange for a correct sketch. */
:root {
  --ink: #0e343e;
  --ink-soft: rgba(14, 52, 62, 0.7);
  --ink-faint: rgba(14, 52, 62, 0.5);
  --rule: rgba(14, 52, 62, 0.16);
  --page: #fdfbf7;
  --sand: #f5f0e8;
  --blue: #c5d8de;
  --orange: #f6bc83;
  --orange-wash: rgba(246, 188, 131, 0.22);
  --wrong: #b0432b;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --grid-size: 7;
  --measure: 60rem;
  --gutter: 1.25rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
}

p {
  margin: 0 0 1rem;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.lede {
  max-width: 40rem;
  color: var(--ink-soft);
  text-wrap: balance;
}

/* ---------- hero: the paper ---------- */

.hero {
  padding: clamp(3rem, 9vw, 5.5rem) var(--gutter) clamp(2rem, 5vw, 3rem);
  text-align: center;
}

.hero h1 {
  max-width: 24ch;
  margin: 0 auto 1.4rem;
  font-size: clamp(2rem, 5.6vw, 3.5rem);
  line-height: 1.1;
}

.authors {
  margin-bottom: 0.2rem;
  font-size: clamp(1rem, 2.6vw, 1.15rem);
  font-weight: 600;
}

.affiliation {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.affiliation span {
  margin-left: 0.6rem;
  color: var(--ink-faint);
}

.paper-links {
  margin-top: 1.6rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.paper-links a {
  padding: 0.55rem 1.4rem;
  background: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.paper-links a:hover {
  background: transparent;
  color: var(--ink);
}

/* ---------- the puzzle and the answer from memory ---------- */

.guess {
  padding-bottom: clamp(3rem, 8vw, 5rem);
}

.try {
  margin-bottom: 1rem;
  text-align: center;
}

.card {
  max-width: 52rem;
  margin: 0 auto;
  background: var(--sand);
  border-radius: 20px;
  padding: clamp(1.25rem, 4vw, 2.25rem);
}

.brief {
  display: flex;
  align-items: center;
  gap: 1.5rem 2.5rem;
}

.brief-text {
  flex: 1;
}

.card-label {
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

/* The description recedes; the places and directions carry the puzzle. */
.story {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.9vw, 1.4rem);
  line-height: 1.6;
  color: rgba(14, 52, 62, 0.6);
}

.place,
.dir {
  color: var(--ink);
  font-weight: 600;
}

.place,
.compass-label {
  white-space: nowrap;
}

.story .dir {
  cursor: pointer;
  border-radius: 4px;
  text-decoration: underline dotted var(--ink-faint);
  text-underline-offset: 0.22em;
}

.story .dir.is-active {
  background: #fff;
  box-shadow: 0 0 0 0.2em #fff;
  text-decoration-color: transparent;
}

.dial {
  flex: 0 0 auto;
  width: 9.5rem;
  margin: 0;
  text-align: center;
}

.dial svg {
  display: block;
  width: 100%;
}

.dial-face {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 1.5;
}

.dial text {
  font-family: var(--sans);
  font-size: 7.5px;
  fill: var(--ink-faint);
  text-anchor: middle;
  dominant-baseline: central;
}

.dial text.is-major {
  font-size: 9.5px;
  font-weight: 700;
  fill: var(--ink);
}

.dial-hand {
  transform: rotate(calc(var(--hour, 12) * 30deg));
  transition: transform 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.dial-hand line {
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.dial-hand path,
.dial-pivot {
  fill: var(--ink);
}

.dial figcaption {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.ask {
  margin-top: clamp(1.25rem, 3.5vw, 2rem);
  padding: clamp(1.1rem, 3.5vw, 1.75rem);
  background: #fff;
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem 2.5rem;
}

.ask-text {
  flex: 1 1 16rem;
}

.question {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 3.4vw, 1.7rem);
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.instruction {
  color: var(--ink-soft);
  margin-bottom: 0;
}

.guess-note {
  margin: 0.9rem 0 0;
  font-weight: 600;
}

.compass {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 5.2rem);
  grid-auto-rows: 4rem;
  gap: 0.4rem;
  margin: 0 auto;
}

.compass-option,
.compass-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.74rem;
  line-height: 1.2;
}

.compass-option {
  background: var(--page);
  border: 1.5px solid var(--rule);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.compass-option:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.compass-arrow {
  font-size: 1.25rem;
  line-height: 1.1;
}

.compass-option[aria-pressed="true"] {
  background: var(--blue);
  border-color: var(--ink);
  font-weight: 700;
}

.compass-option.is-answer {
  box-shadow: 0 0 0 3px var(--orange);
  border-color: var(--orange);
}

.compass-center {
  font-weight: 700;
}

.compass-center span {
  font-size: 1.5rem;
  line-height: 1.2;
}

/* ---------- the sketch ---------- */

.sketch {
  padding: clamp(1rem, 3vw, 2rem) 0 clamp(3.5rem, 9vw, 6rem);
}

.sketch h2,
.bridge h2 {
  text-align: center;
}

.sketch .lede,
.bridge .lede {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.workspace {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 26rem);
  gap: 2rem 3rem;
  align-items: start;
}

.checklist {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  color: var(--ink-soft);
}

.checklist li {
  display: flex;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  transition: background 0.2s;
}

.checklist .mark {
  flex: 0 0 1.1rem;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
}

.checklist .is-pending .mark {
  color: var(--ink-faint);
}

.checklist .is-bad .mark,
.drawn {
  color: var(--wrong);
}

.checklist .is-active {
  background: var(--sand);
}

.checklist .drawn {
  display: block;
  font-size: 0.86rem;
}

.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.3rem 0.85rem 0.3rem 0.6rem;
  background: #fff;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, opacity 0.15s;
}

.chip span {
  font-size: 1.3rem;
  line-height: 1;
}

.chip.is-placed {
  opacity: 0.5;
}

.chip:hover {
  border-color: var(--ink);
}

.chip[aria-pressed="true"] {
  opacity: 1;
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink);
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 0.6rem;
}

.button {
  min-height: 2.75rem;
  padding: 0.5rem 1.2rem;
  background: var(--ink);
  color: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.button-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}

.button:hover {
  opacity: 0.85;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 14px 30px -18px rgba(14, 52, 62, 0.45);
  transition: background 0.4s, border-color 0.4s;
}

.board.is-solved {
  background: #fdf1e3;
  border-color: var(--orange);
}

.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  grid-template-rows: repeat(var(--grid-size), 1fr);
}

.cell {
  padding: 0;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}

.cell:nth-child(7n) {
  border-right: 0;
}

.cell:nth-last-child(-n + 7) {
  border-bottom: 0;
}

.cell:focus-visible {
  outline-offset: -3px;
}

@media (hover: hover) {
  .board.is-holding .cell:hover {
    background: var(--sand);
  }
}

.tokens,
.sightline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.token {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% / var(--grid-size));
  height: calc(100% / var(--grid-size));
  display: grid;
  place-items: center;
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%));
  transition: transform 0.35s ease;
}

.token span {
  display: grid;
  place-items: center;
  width: 82%;
  height: 82%;
  border-radius: 50%;
  font-size: clamp(1.3rem, 5.6vw, 1.9rem);
  line-height: 1;
  animation: pop 0.25s ease-out;
}

.token.is-selected span {
  box-shadow: 0 0 0 2px var(--ink);
  background: #fff;
}

.token.is-queried span {
  background: var(--orange);
}

@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

.sightline line {
  stroke: var(--ink);
  stroke-width: 0.045;
  stroke-dasharray: 0.14 0.1;
  opacity: 0;
  transition: opacity 0.4s;
}

.sightline.is-visible line {
  opacity: 1;
}

.progress {
  margin: 0.8rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.reveal {
  max-width: 44rem;
  margin: 2.5rem auto 0;
  padding: 1.1rem 1.5rem;
  background: var(--orange-wash);
  border-radius: 14px;
  font-size: 1.15rem;
  text-align: center;
  animation: pop 0.3s ease-out;
}

/* ---------- from sketch to ASCII ---------- */

.bridge {
  padding: clamp(3.5rem, 9vw, 6rem) 0;
  background: var(--sand);
}

.translation {
  max-width: 44rem;
  margin: 2.5rem auto 0;
  padding: clamp(1.25rem, 4vw, 2.25rem);
  background: #fff;
  border-radius: 20px;
}

.translation-pair {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.25rem 2.5rem;
}

.minimap {
  display: grid;
  grid-template-columns: repeat(var(--cols), 2.9rem);
  grid-auto-rows: 2.9rem;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
}

.minimap span {
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: 0 0 0 0.5px var(--rule);
}

.translation-arrow {
  font-size: 2rem;
  line-height: 1;
}

.ascii {
  margin: 0;
  padding: 1rem 1.25rem;
  background: var(--orange-wash);
  border: 2px solid var(--orange);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: clamp(1rem, 3.6vw, 1.3rem);
  line-height: 1.25;
}

.ascii .line {
  display: block;
  opacity: 0;
}

.translation.is-in-view .ascii .line {
  animation: write 0.25s ease-out forwards;
  animation-delay: calc(var(--i) * 90ms);
}

@keyframes write {
  to {
    opacity: 1;
  }
}

.key {
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.4rem;
  font-size: 0.95rem;
}

.key code {
  font-family: var(--mono);
  font-weight: 700;
  margin-right: 0.3rem;
}

.key .place {
  font-weight: 400;
}

.translation figcaption {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ---------- closing question ---------- */

.closing {
  padding: clamp(4rem, 11vw, 7.5rem) 0;
  background: var(--ink);
  color: #fff;
  text-align: center;
}

.closing h2 {
  max-width: 18ch;
  margin: 0 auto 1.5rem;
  font-size: clamp(2rem, 6vw, 3.4rem);
}

.closing .wrap > p {
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
  font-size: 1.2rem;
  opacity: 0.9;
  text-wrap: balance;
}

/* Learn, test, result: three cards read left to right, one arrow in each gap. */
.lesson {
  --step-gap: 2.75rem;
  margin: 3rem auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--step-gap);
  text-align: left;
}

.step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.4rem 1.4rem 1.5rem;
  background: #fff;
  border-radius: 18px;
  color: var(--ink);
}

.step + .step::before {
  content: "→";
  position: absolute;
  top: 50%;
  left: calc(-1 * var(--step-gap));
  width: var(--step-gap);
  transform: translateY(-50%);
  color: #fff;
  font-size: 1.6rem;
  text-align: center;
}

.step-kicker {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.step h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.2;
}

.step p {
  margin: 0;
  font-size: 0.95rem;
}

.step .snippet {
  padding-left: 0.8rem;
  border-left: 3px solid var(--rule);
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.snippet strong {
  color: var(--ink);
}

.step-flow {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-faint);
}

.step pre {
  margin: 0;
  font-family: var(--mono);
  line-height: 1.2;
}

.drawn-grid {
  align-self: flex-start;
  padding: 0.7rem 0.9rem;
  background: var(--orange-wash);
  border: 2px solid var(--orange);
  border-radius: 10px;
  font-size: 0.95rem;
}

.absent {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* An empty grid, struck through: the test neither shows nor asks for one. */
.ghost-grid {
  position: relative;
  flex: 0 0 auto;
  padding: 0.4rem 0.5rem;
  border: 2px dashed var(--rule);
  border-radius: 10px;
  font-size: 0.8rem;
  color: rgba(14, 52, 62, 0.25);
}

.ghost-grid::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 1px),
    var(--wrong) calc(50% - 1px),
    var(--wrong) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
}

.absent ul,
.answers {
  list-style: none;
  margin: 0;
  padding: 0;
}

.absent li {
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.absent li::before {
  content: "✕ ";
  color: var(--wrong);
}

.answers {
  display: grid;
  gap: 0.6rem;
}

.answers li {
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--rule);
  border-radius: 10px;
}

.answers .when {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.answers .said {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
}

.answers .verdict {
  float: right;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.answers .before .verdict {
  color: var(--wrong);
}

.answers .after {
  background: var(--orange-wash);
  border-color: var(--orange);
}

.lesson figcaption {
  grid-column: 1 / -1;
  margin-top: -1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.closing .wrap > .finding {
  max-width: 24ch;
  margin: 3.5rem auto 1.5rem;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4.6vw, 2.6rem);
  font-weight: 600;
  line-height: 1.15;
  opacity: 1;
  text-wrap: balance;
}

.closing .wrap > .closing-note {
  margin-bottom: 0;
  font-size: 0.98rem;
  opacity: 0.75;
}

.closing-note a {
  font-weight: 600;
  white-space: nowrap;
}

.closing .wrap > .afterthought {
  margin: 3.5rem auto 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
}

.closing :focus-visible {
  outline-color: #fff;
}

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  .affiliation span {
    display: block;
    margin-left: 0;
  }

  .brief {
    flex-direction: column;
    align-items: stretch;
  }

  .dial {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: auto;
    text-align: left;
  }

  .dial svg {
    width: 7rem;
  }

  .dial figcaption {
    margin: 0;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .paper {
    width: 100%;
    max-width: 26rem;
    margin: 0 auto;
  }

  .checklist {
    margin-bottom: 1rem;
    font-size: 0.97rem;
  }

  .checklist li {
    padding: 0.25rem 0.3rem;
  }

  .translation-arrow {
    transform: rotate(90deg);
    flex-basis: 100%;
    text-align: center;
  }
}

@media (max-width: 820px) {
  .lesson {
    grid-template-columns: minmax(0, 1fr);
    max-width: 26rem;
  }

  .step + .step::before {
    content: "↓";
    top: calc(-1 * var(--step-gap));
    left: 0;
    width: 100%;
    height: var(--step-gap);
    line-height: var(--step-gap);
    transform: none;
  }
}

@media (max-width: 420px) {
  /* Four buttons do not fit one row on a phone; two by two reads better than three plus one. */
  .paper-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    max-width: 16rem;
    margin-left: auto;
    margin-right: auto;
  }

  .paper-links a {
    text-align: center;
  }
}

@media (max-width: 380px) {
  .compass {
    grid-template-columns: repeat(3, 4.8rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .token,
  .token span,
  .dial-hand,
  .reveal,
  .translation.is-in-view .ascii .line {
    transition: none;
    animation: none;
  }

  .ascii .line {
    opacity: 1;
  }
}
