@font-face {
  font-family: "Courier Prime";
  src: url("assets/fonts/courier-prime-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #292923;
  --soft-ink: #55534a;
  --faint-ink: #6b685e;
  --paper: #efebe0;
  --rule: rgb(66 62 49 / 21%);
  --gutter: clamp(24px, 4.85vw, 86px);
  --site-font: "Courier Prime", "Courier New", monospace;
  font: 400 16px/1.45 var(--site-font);
  font-synthesis: none;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:where(h1, h2, h3, b, strong) { font-weight: inherit; }
button[hidden], [hidden] { display: none !important; }

.experience {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 440px;
  overflow: hidden;
}

.paper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 52% 42%, #f7f3e9 0%, #f1eee4 41%, #e7e2d6 82%, #ded9cc 100%);
  transition: opacity 700ms ease;
}
.paper::before {
  position: absolute;
  inset: 0;
  content: "";
  background: url("assets/paper-grain.png") repeat;
  mix-blend-mode: multiply;
  opacity: .55;
}

#field { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; }
.masthead, .colophon {
  position: absolute;
  z-index: 3;
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.masthead {
  top: 0;
  height: clamp(65px, 10vh, 91px);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  display: flex;
  gap: 13px;
  align-items: center;
  font-size: clamp(15px, 1.5vw, 24px);
  letter-spacing: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.imprint {
  display: block;
  position: relative;
  width: 26px;
  height: 22px;
  transform: rotate(-17deg);
}
.imprint i {
  position: absolute;
  inset: 1px;
  border: 1px solid currentColor;
  border-radius: 48% 34% 42% 47% / 63% 48% 46% 39%;
}
.imprint i:nth-child(2) { inset: 4px 5px 4px 4px; }
.imprint i:nth-child(3) { inset: 7px 8px 7px 7px; }

.sound, .restart, .text-action {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.sound {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  font-size: clamp(14px, 1.25vw, 20px);
  white-space: nowrap;
}
.waveform { display: inline-flex; align-items: center; gap: 3px; height: 16px; }
.waveform i { width: 1px; height: 5px; background: currentColor; }
.waveform i:nth-child(2) { height: 12px; }
.waveform i:nth-child(3) { height: 8px; }
.waveform i:nth-child(4) { height: 4px; }
.sound[aria-pressed="true"] .waveform i { animation: listen 1.25s ease-in-out infinite alternate; }
.sound[aria-pressed="true"] .waveform i:nth-child(2) { animation-delay: -.85s; }
.sound[aria-pressed="true"] .waveform i:nth-child(3) { animation-delay: -.45s; }
@keyframes listen { to { transform: scaleY(.4); } }

.caption {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  top: 50%;
  width: min(42%, 590px);
  transform: translateY(-50%);
  pointer-events: none;
  transition: opacity 380ms ease, transform 600ms ease;
}
.chapter {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 22px;
  font-size: clamp(13px, 1.125vw, 18px);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--soft-ink);
}
.chapter span { width: 16px; height: 1px; background: currentColor; opacity: .62; }
.caption h1 {
  margin: 0;
  font-size: clamp(36px, 3.75vw, 60px);
  line-height: 1.12;
  letter-spacing: 1px;
}
.instruction {
  max-width: 32ch;
  margin: clamp(18px, 2.4vw, 40px) 0 0;
  font-size: clamp(15px, 1.25vw, 20px);
  line-height: 1.45;
  letter-spacing: .5px;
  color: var(--soft-ink);
  text-wrap: pretty;
}
.text-action {
  margin-top: 14px;
  min-height: 42px;
  font-size: clamp(15px, 1.25vw, 20px);
  letter-spacing: .5px;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgb(75 69 59 / 46%);
  text-underline-offset: 5px;
  pointer-events: auto;
}
.text-action:hover { text-decoration-color: currentColor; }
button:focus-visible { outline: 1px solid currentColor; outline-offset: 5px; }

.object-target, .connector-target, .opening-target {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 1;
  touch-action: none;
}
.object-target[data-rotate="true"] { cursor: grab; }
.object-target[data-dragging="true"] { cursor: grabbing; }
.connector-target, .opening-target { z-index: 2; }
.object-note {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--soft-ink);
  font-size: .8rem;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 260ms ease;
}
.connector-target .object-note { top: calc(100% + 1px); }
.opening-target .object-note {
  top: calc(100% + clamp(21px, 3.4vh, 34px));
  padding: 3px 8px;
  color: var(--ink);
  background: rgb(244 240 231 / 90%);
}

.colophon {
  bottom: 0;
  height: clamp(57px, 9.7vh, 84px);
  border-top: 1px solid var(--rule);
  color: var(--soft-ink);
  font-size: clamp(13px, 1.125vw, 18px);
}
.progress { display: flex; gap: clamp(14px, 2.5vw, 36px); padding: 0; margin: 0; list-style: none; }
.progress li { display: flex; align-items: center; gap: 7px; color: var(--faint-ink); }
.progress li span { display: block; width: 5px; height: 5px; border: 1px solid currentColor; border-radius: 50%; }
.progress li[aria-current="step"] { color: var(--ink); }
.progress li[aria-current="step"] span { background: currentColor; }
.headphones { margin: 0; white-space: nowrap; }
.restart { min-height: 44px; text-decoration: underline; text-underline-offset: 4px; }

[data-phase="crossing"] .caption { opacity: 0; transform: translateY(-48%); }
[data-phase="crossing"] .masthead, [data-phase="crossing"] .colophon { opacity: 0; pointer-events: none; }
[data-phase="shore"] {
  color: #fcf7ed;
  --ink: #fcf7ed;
  --soft-ink: #fcf7ed;
  --faint-ink: #ede6d7;
  --rule: rgb(252 247 237 / 43%);
}
[data-phase="shore"] .caption { text-shadow: 0 1px 16px rgb(4 12 13 / 70%); }
[data-phase="shore"] .text-action { text-decoration-color: currentColor; }
.notice { position: absolute; top: 38%; left: var(--gutter); background: var(--paper); padding: 1rem; }

@media (max-width: 780px) {
  .caption { top: clamp(105px, 14.5%, 156px); width: min(88%, 490px); transform: none; }
  .caption h1 { font-size: clamp(24px, 7.5vw, 50px); }
  .chapter { margin-bottom: 14px; }
  .instruction { margin-top: 12px; max-width: 310px; }
  .text-action { margin-top: 5px; }
  [data-phase="crossing"] .caption { transform: translateY(-8px); }
}

@media (max-width: 520px) {
  .masthead, .colophon { gap: 12px; }
  .wordmark { font-size: .75rem; letter-spacing: .17em; gap: 9px; }
  .headphones { display: none; }
  .colophon { min-height: 54px; }
}
@media (max-height: 565px) and (max-width: 780px) {
  .caption { top: 36%; width: 43%; }
  .caption h1 { font-size: clamp(24px, 4.4vw, 37px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
