:root {
  --ink: #0b0f19;
  --paper: #f4ecd8;
  --lilac: #b9a8dd;
  --mint: #3fd49a;
  --dusk: #1b1637;

  --pixel: 'Pixelify Sans', monospace;
  --text: 'IBM Plex Sans', system-ui, sans-serif;
  --edge: 4px;
}

body {
  margin: 0;
  background: var(--dusk);
  color: var(--ink);
  font-family: var(--text);
}

/* Offset right on wide viewports so the near bridge spans and train remain uncovered on the left. */
body:has(.plaque) {
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  padding: 48px clamp(24px, 7vw, 128px) 48px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 3px solid var(--mint);
}

button {
  font-family: var(--pixel);
  cursor: pointer;
}

a:hover,
button:hover {
  background: var(--mint);
  color: var(--ink);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
}

#river {
  position: fixed;
  top: 0;
  left: 0;
  image-rendering: pixelated;
}

/* 0.78 alpha is the lowest opacity that keeps text above WCAG AA over pure white scene pixels (--paper 8.5:1, --mint 5.3:1). */
.plaque {
  --radius: 20px;
  position: relative;
  width: 100%;
  max-width: 560px;
  box-sizing: border-box;
  padding: 28px 32px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgb(14 11 32 / 0.78);
  color: var(--paper);
  border: var(--edge) solid var(--paper);
  border-radius: var(--radius);
  box-shadow: 12px 12px 0 var(--ink);
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s,
    visibility 0s;
}

.plaque.folded {
  transform: translateX(calc(100% + 140px));
  opacity: 0;
  visibility: hidden;
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s 0.1s,
    visibility 0s 0.35s;
}

.fold,
.unfold {
  position: absolute;
  top: -18px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 4px 4px 0 var(--ink);
}

.fold {
  right: 20px;
}

.unfold {
  left: 50%;
  transform: translateX(-50%);
}

/* Expands the 32px chip to a 44px touch target. */
.fold::after,
.unfold::after {
  content: '';
  position: absolute;
  inset: -6px;
}

.fold svg,
.unfold svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  shape-rendering: crispEdges;
}

.rail {
  position: fixed;
  right: 12px;
  top: 24px;
  padding: 24px 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgb(14 11 32 / 0.78);
  color: var(--paper);
  border: var(--edge) solid var(--paper);
  border-radius: 14px;
  box-shadow: 8px 8px 0 var(--ink);
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  visibility: hidden;
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s,
    visibility 0s 0.35s;
}

.rail.here {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s,
    opacity 0.2s 0.1s,
    visibility 0s;
}

.rail a {
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: var(--paper);
  border: 0;
  border-radius: 8px;
}

.rail img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

/* Turns the #f4ecd8 SVG icon paths dark against the --mint hover background. */
.rail a:hover img,
.rail a:focus-visible img {
  filter: brightness(0);
}

@media (prefers-reduced-motion: reduce) {
  .plaque.folded,
  .rail {
    transform: none;
  }

  .plaque,
  .rail.here {
    transition:
      opacity 0.12s,
      visibility 0s;
  }

  .plaque.folded,
  .rail {
    transition:
      opacity 0.12s,
      visibility 0s 0.12s;
  }
}

.plaque header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 22px;
  align-items: center;
  margin-bottom: 6px;
}

.plaque header img {
  grid-row: 1 / 3;
  width: 112px;
  height: 112px;
  box-sizing: border-box;
  border: var(--edge) solid var(--paper);
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 6px 6px 0 var(--ink);
}

h1 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: clamp(34px, 4.5vw, 52px);
  line-height: 1;
  letter-spacing: 0.01em;
}

.plaque h1 {
  align-self: end;
}

.plaque h1,
.plaque header p {
  text-shadow: 3px 3px 0 var(--ink);
}

.plaque header p {
  align-self: start;
  margin: 6px 0 0;
  font-family: var(--pixel);
  font-size: 20px;
  color: var(--mint);
}

.plaque > p {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
}

.plaque ul {
  margin: 6px 0 0;
  padding: 14px 0 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 2px;
  border-top: var(--edge) solid var(--paper);
  font-family: var(--pixel);
  font-size: 20px;
}

.plaque li {
  position: relative;
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 0.35em;
}

/* A row without a link is one run of text: it breaks beside its icon rather than dropping below it. */
.plaque li:not(:has(a)) {
  flex-wrap: nowrap;
}

/* 12x12 SVG icons rendered at 2x to keep integer pixel edges. */
.plaque li img {
  flex: none;
  width: 24px;
  height: 24px;
  margin-right: 0.25em;
  image-rendering: pixelated;
}

/* Expands the link hit target across the entire list item, including unlinked prefix words. */
.plaque li a::after {
  content: '';
  position: absolute;
  inset: 0;
}

@media (max-width: 900px) {
  body:has(.plaque) {
    padding-inline: 16px;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  body:has(.plaque) {
    padding: 24px 16px 16px;
  }

  .plaque {
    --radius: 16px;
    padding: 16px 18px;
    gap: 8px;
  }

  .plaque header {
    column-gap: 14px;
    margin-bottom: 2px;
  }

  .plaque header img {
    width: clamp(60px, 18vw, 76px);
    height: clamp(60px, 18vw, 76px);
    border-radius: 10px;
    box-shadow: 4px 4px 0 var(--ink);
  }

  .plaque h1 {
    font-size: clamp(26px, 7.5vw, 34px);
  }

  .plaque header p {
    margin-top: 4px;
    font-size: 16px;
  }

  .plaque > p {
    font-size: 15px;
    line-height: 1.45;
  }

  .plaque ul {
    margin-top: 2px;
    padding-top: 6px;
    column-gap: 12px;
    row-gap: 0;
    font-size: 16px;
  }
}

/* ?debug instrument tiles: a pixel canvas over #river, with transparent hit targets laid over each tile. */
.almanac canvas {
  position: fixed;
  top: 0;
  left: 0;
  image-rendering: pixelated;
  pointer-events: none;
}

.almanac button {
  position: fixed;
  padding: 0;
  background: none;
  border: 0;
}

.almanac button:focus-visible {
  outline-offset: 2px;
}

.almanac button::after {
  padding: 2px 8px;
  background: var(--dusk);
  color: var(--paper);
  border: 2px solid var(--paper);
  font-family: var(--pixel);
  font-size: 15px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  visibility: hidden;
}

.corner {
  position: fixed;
  right: 8px;
  bottom: 6px;
  margin: 0;
  color: var(--paper);
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-shadow: 1px 1px 0 var(--ink);
}

.corner a {
  border-bottom-width: 1px;
}

.almanac button::after {
  content: attr(data-name);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
}

.almanac button:hover::after,
.almanac button:focus::after {
  visibility: visible;
}

.not-found {
  padding: 64px 24px;
  color: var(--paper);
}

.not-found h1 {
  margin-bottom: 20px;
}

.not-found p {
  margin: 0 0 12px;
  font-size: 17px;
  line-height: 1.6;
}

.not-found .home {
  text-align: center;
}

.not-found .status {
  margin-bottom: 8px;
  font-family: var(--pixel);
  font-size: 20px;
  color: var(--lilac);
}

[hidden] {
  display: none;
}
