:root {
  --navy: #07131f;
  --cream: #fff7e8;
  --gold: #d5a85e;
  --nav-height: 64px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--navy);
}

body {
  margin: 0;
  background: var(--navy);
  color: var(--cream);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px;
  background: var(--cream);
  color: var(--navy);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: none;
}

.site-nav {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(28px, 4.6vw, 78px);
  border-bottom: 1px solid #ffffff22;
  background: #05101bf5;
}

.brand {
  color: var(--cream);
  text-decoration: none;
}

.brand span {
  display: block;
  font: italic 27px/.85 Georgia, serif;
}

.brand small {
  font: 700 7px Arial, sans-serif;
  letter-spacing: .3em;
  text-transform: uppercase;
}

.site-nav nav {
  display: flex;
  gap: clamp(20px, 3vw, 50px);
}

.site-nav nav a {
  color: #fffbd0;
  font: 700 9px "Courier New", monospace;
  letter-spacing: .15em;
  text-decoration: none;
  text-transform: uppercase;
}

.writing-landing {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100svh;
  padding-top: var(--nav-height);
}

.landing-intro {
  position: absolute;
  z-index: 10;
  top: 86px;
  left: 50%;
  text-align: center;
  transform: translateX(-50%);
}

.landing-intro h1 {
  margin: 0;
  white-space: nowrap;
  font: italic clamp(72px, 7vw, 112px)/.8 Georgia, serif;
  letter-spacing: -.06em;
}

.landing-intro span {
  display: block;
  margin-top: 30px;
  font: italic 16px Georgia, serif;
}

.portal {
  position: relative;
  min-height: calc(100svh - var(--nav-height));
  overflow: hidden;
}

.portal > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portal-alt {
  border-left: 1px solid #ffffff22;
}

.portal-copy {
  position: absolute;
  z-index: 4;
  top: 38%;
  left: 10%;
  width: 70%;
}

.portal-haiku .portal-copy {
  left: 57%;
}

.portal-label {
  color: var(--gold);
  font: 700 10px "Courier New", monospace;
  letter-spacing: .25em;
  text-transform: uppercase;
}

.portal h2 {
  margin: 0;
  font: clamp(48px, 5.2vw, 84px)/.9 Georgia, serif;
  letter-spacing: -.05em;
  text-shadow: 0 3px 28px #0009;
}

.portal a {
  display: inline-block;
  margin-top: 27px;
  padding: 17px 24px;
  border: 1px solid;
  background: #05101bbb;
  color: var(--gold);
  font: 700 10px "Courier New", monospace;
  letter-spacing: .2em;
  text-decoration: none;
  text-transform: uppercase;
}

/* Transparent hit target aligned to the moon already present in the artwork. */
.moon-trigger {
  position: absolute;
  z-index: 12;
  top: 5.4%;
  left: 26.7%;
  width: 11.2%;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.moon-trigger:focus-visible {
  outline: 1px solid #ffffff99;
  outline-offset: 4px;
}

.night-world {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
  min-height: 100svh;
  overflow: hidden;
  background: #000;
  isolation: isolate;
  --journey-progress: 0;
  --background-x: 0%;
  --background-y: 0%;
  --background-scale: 1;
  --scroll-cue-opacity: 1;
}

.night-open {
  overflow: hidden;
}

.night-open .public-world {
  display: none;
}

.night-open .skip-link {
  display: none;
}

.night-open .night-world {
  display: block;
}

.lunar-journey {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.lunar-journey::-webkit-scrollbar {
  display: none;
}

.lunar-study {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100svh;
}

.lunar-journey::after {
  display: block;
  height: 760svh;
  content: "";
}

.lunar-background {
  position: absolute;
  inset: -4%;
  width: 108%;
  height: 108%;
  display: block;
  object-fit: cover;
  object-position: center center;
  transform: translate3d(var(--background-x), var(--background-y), 0) scale(var(--background-scale));
  transform-origin: 58% 63%;
  filter: contrast(1.02);
  will-change: transform;
}

.encounter {
  position: absolute;
  z-index: 2;
  opacity: var(--encounter-opacity, 0);
  transform: translate3d(0, var(--encounter-drift, 32px), 0);
  transition: opacity 120ms linear;
  pointer-events: none;
  will-change: opacity, transform;
}

.encounter.is-visible {
  pointer-events: auto;
}

.encounter-one {
  top: 62%;
  left: 18%;
}

.encounter-two {
  top: 25%;
  right: 8%;
}

.encounter-three {
  top: 76%;
  left: 45%;
}

.encounter-four {
  top: 40%;
  left: 9%;
}

.encounter-five {
  top: 68%;
  right: 7%;
}

.encounter-six {
  top: 17%;
  left: 33%;
}

.encounter-seven {
  top: 54%;
  right: 4%;
}

.encounter-eight {
  top: 11%;
  left: 4%;
}

.encounter-nine {
  top: 31%;
  right: 12%;
}

.encounter-ten {
  top: 65%;
  left: 39%;
}

.encounter-eleven {
  top: 20%;
  right: 5%;
}

.encounter-twelve {
  top: 48%;
  left: 15%;
}

.encounter-trigger {
  position: relative;
  display: grid;
  grid-template-columns: 25px 62px max-content;
  grid-template-areas: "node leader copy";
  align-items: center;
  padding: 18px;
  border: 0;
  background: transparent;
  color: #f5f2e8;
  text-align: left;
  cursor: pointer;
}

.encounter-node {
  position: relative;
  z-index: 4;
  grid-area: node;
  width: 18px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #0006, 0 0 18px #0008;
  transition: transform 260ms ease, background 260ms ease;
}

.encounter-node i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.2);
  transition: opacity 160ms ease, transform 220ms ease;
}

.encounter-leader {
  position: relative;
  z-index: 3;
  grid-area: leader;
  width: 54px;
  height: 1px;
  background: currentColor;
  opacity: .72;
  transform-origin: left;
  transition: transform 320ms ease;
}

.encounter-copy {
  position: relative;
  z-index: 3;
  display: grid;
  grid-area: copy;
  min-width: 250px;
  max-width: 330px;
  padding-left: 2px;
  text-shadow: 0 1px 8px #000, 0 2px 18px #000;
  transition: opacity 100ms linear;
}

.encounter-copy::before {
  position: absolute;
  z-index: 0;
  inset: -14px -18px -13px;
  border: 1px solid #f5f2e8cc;
  clip-path: polygon(0 9%, 96% 0, 100% 88%, 4% 100%);
  content: "";
  opacity: 0;
  transform: scale(.94);
  transition: opacity 140ms ease, transform 180ms ease;
}

.encounter-copy > * {
  position: relative;
  z-index: 1;
}

.encounter-number {
  margin-bottom: 4px;
  font: 700 11px/1 "Courier New", monospace;
  letter-spacing: .18em;
  opacity: .65;
}

.encounter-copy strong {
  font: 600 clamp(28px, 2.2vw, 35px)/1.04 Georgia, serif;
  letter-spacing: -.015em;
  text-wrap: balance;
}

.encounter-copy small {
  margin-top: 7px;
  font: 700 11px/1.2 "Courier New", monospace;
  letter-spacing: .09em;
  text-transform: uppercase;
  opacity: .74;
}

.encounter-preview {
  position: absolute;
  z-index: 2;
  top: 4px;
  left: 84px;
  display: grid;
  width: min(330px, 56vw);
  min-height: 92px;
  align-content: center;
  gap: 12px;
  padding: 18px 22px 17px 30px;
  background: #ede8da;
  color: #171512;
  clip-path: polygon(0 9%, 96% 0, 100% 87%, 5% 100%);
  opacity: 0;
  transform: scaleX(.03);
  transform-origin: left center;
  transition: transform 360ms cubic-bezier(.22,.8,.24,1), opacity 80ms linear;
}

body[data-active-piece="loom"] .encounter-one .encounter-preview,
body[data-active-piece="cross-country"] .encounter-two .encounter-preview,
body[data-active-piece="public-crying"] .encounter-three .encounter-preview,
body[data-active-piece="cummins-diesel"] .encounter-four .encounter-preview,
body[data-active-piece="happy-go-something"] .encounter-five .encounter-preview,
body[data-active-piece="their-arms-behind-them"] .encounter-six .encounter-preview,
body[data-active-piece="jane"] .encounter-seven .encounter-preview,
body[data-active-piece="wild-honey"] .encounter-eight .encounter-preview,
body[data-active-piece="coitus"] .encounter-nine .encounter-preview,
body[data-active-piece="sedona"] .encounter-ten .encounter-preview {
  view-transition-name: writing-surface;
}

.encounter.align-left .encounter-trigger {
  grid-template-columns: max-content 62px 25px;
  grid-template-areas: "copy leader node";
}

.encounter.align-left .encounter-copy {
  padding-right: 2px;
  padding-left: 0;
  text-align: right;
}

.encounter.align-left .encounter-leader {
  justify-self: end;
  transform-origin: right;
}

.encounter.align-left .encounter-preview {
  right: 84px;
  left: auto;
  transform-origin: right center;
}

.encounter-preview span,
.encounter-preview em {
  opacity: 0;
  transition: opacity 180ms ease;
}

.encounter-preview span {
  display: -webkit-box;
  overflow: hidden;
  font: 16px/1.35 Georgia, serif;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.encounter-preview em {
  font: normal 700 9px/1 "Courier New", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.encounter-trigger:hover .encounter-node,
.keyboard-input .encounter-trigger:focus-visible .encounter-node,
.encounter-trigger[aria-expanded="true"] .encounter-node {
  background: #ede8da;
  color: #171512;
  transform: scale(1.22);
}

.encounter-trigger:hover .encounter-node i,
.keyboard-input .encounter-trigger:focus-visible .encounter-node i,
.encounter-trigger[aria-expanded="true"] .encounter-node i {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.encounter-trigger:hover .encounter-leader,
.keyboard-input .encounter-trigger:focus-visible .encounter-leader,
.encounter-trigger[aria-expanded="true"] .encounter-leader {
  transform: scaleX(1.12);
}

.encounter-trigger:hover .encounter-preview,
.keyboard-input .encounter-trigger:focus-visible .encounter-preview,
.encounter-trigger[aria-expanded="true"] .encounter-preview {
  opacity: 1;
  transform: scaleX(1);
  transition-delay: 180ms;
}

.encounter-trigger:hover .encounter-preview span,
.encounter-trigger:hover .encounter-preview em,
.keyboard-input .encounter-trigger:focus-visible .encounter-preview span,
.keyboard-input .encounter-trigger:focus-visible .encounter-preview em,
.encounter-trigger[aria-expanded="true"] .encounter-preview span,
.encounter-trigger[aria-expanded="true"] .encounter-preview em {
  opacity: 1;
  transition-delay: 320ms;
}

.encounter-trigger:hover .encounter-copy,
.keyboard-input .encounter-trigger:focus-visible .encounter-copy,
.encounter-trigger[aria-expanded="true"] .encounter-copy {
  opacity: 0;
  transition-delay: 240ms;
}

.encounter-trigger:hover .encounter-copy::before,
.keyboard-input .encounter-trigger:focus-visible .encounter-copy::before,
.encounter-trigger[aria-expanded="true"] .encounter-copy::before {
  opacity: 1;
  transform: scale(1);
}

.keyboard-input .encounter-trigger:focus-visible {
  outline: none;
}

.keyboard-input .encounter-trigger:focus-visible .encounter-node {
  box-shadow: 0 0 0 3px #000, 0 0 0 5px #fff;
}

.lunar-scroll-cue {
  position: absolute;
  z-index: 2;
  top: 17%;
  left: 50%;
  margin: 0;
  color: #fff;
  font: 700 10px/1 "Courier New", monospace;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 1px 12px #000;
  opacity: var(--scroll-cue-opacity);
  transform: translateX(-50%);
  white-space: nowrap;
}

.lunar-scroll-cue span {
  display: inline-block;
  margin-left: 8px;
}

.reader-overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #5d584d #ded8c9;
}

.reader-overlay[hidden] {
  display: none;
}

.reader-dim {
  position: fixed;
  inset: 0;
  background: #000b;
  backdrop-filter: blur(2px);
}

.reader-surface {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 24px));
  min-height: 100svh;
  margin: 0 auto;
  background: #ede8da;
  color: #171512;
  clip-path: polygon(0 26px, calc(100% - 38px) 0, 100% calc(100% - 30px), 20px 100%);
  box-shadow: 0 0 80px #000c;
  view-transition-name: none;
}

.reader-surface::before {
  position: absolute;
  top: 170px;
  right: 43px;
  content: "01 / 12";
  font: 700 10px/1 "Courier New", monospace;
  letter-spacing: .18em;
  writing-mode: vertical-rl;
  opacity: .48;
}

.reader-surface::after {
  position: absolute;
  top: 255px;
  right: 48px;
  bottom: 100px;
  width: 1px;
  background: #17151224;
  content: "";
}

.reader-open .encounter-one .encounter-preview,
.reader-open .encounter-two .encounter-preview,
.reader-open .encounter-three .encounter-preview,
.reader-open .encounter-four .encounter-preview,
.reader-open .encounter-five .encounter-preview,
.reader-open .encounter-six .encounter-preview,
.reader-open .encounter-seven .encounter-preview,
.reader-open .encounter-eight .encounter-preview,
.reader-open .encounter-nine .encounter-preview,
.reader-open .encounter-ten .encounter-preview {
  view-transition-name: none;
}

.reader-open .reader-surface {
  view-transition-name: writing-surface;
}

.reader-inner {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px) clamp(28px, 7vw, 76px) 100px;
}

.reader-return.reader-close {
  position: fixed;
  z-index: 3;
  top: 22px;
  right: max(58px, calc((100vw - 1320px) / 2 + 58px));
  left: auto;
  width: 92px;
  height: 92px;
  padding: 0;
  border: 1px solid #1715124d;
  font: 300 74px/82px Arial, sans-serif;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
}

@media (min-width: 900px) {
  .reader-inner {
    width: min(74%, 900px);
    margin-right: auto;
    margin-left: 9%;
  }
}

.reader-return.reader-close:hover,
.reader-return.reader-close:focus-visible {
  border-color: #171512;
  text-decoration: none;
}

.reader-return {
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: #171512;
  font: 700 11px/1.2 "Courier New", monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
  cursor: pointer;
}

.reader-return:hover,
.reader-return:focus-visible {
  text-decoration: underline;
  text-underline-offset: 5px;
  outline: none;
}

.reader-header {
  padding: clamp(72px, 12vh, 126px) 0 45px;
  border-bottom: 1px solid #17151233;
}

.reader-header p {
  margin: 0 0 18px;
  font: 700 11px/1.2 "Courier New", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.reader-header h2 {
  max-width: 720px;
  margin: 0;
  font: 600 clamp(48px, 7vw, 72px)/.95 Georgia, serif;
  letter-spacing: -.045em;
  text-wrap: balance;
}

.reader-body {
  padding-top: 48px;
  font: 20px/1.72 Georgia, serif;
}

.reader-body p {
  margin: 0 0 1.45em;
}

.reader-body.reader-poem {
  font-size: clamp(20px, 2vw, 25px);
  line-height: 1.55;
}

.reader-poem p {
  margin-bottom: 2.1em;
}

.reader-poem span {
  display: block;
}

.reader-acrostic strong {
  display: inline-block;
  min-width: .86em;
  font-size: 1.18em;
  font-weight: 800;
}

.reader-fragments .fragment-intro {
  margin-bottom: 2.6em;
  font-size: 24px;
  line-height: 1.48;
}

.reader-fragments .fragment-hinge {
  margin-bottom: 2.5em;
  font-style: italic;
  opacity: .66;
}

.reader-fragments p:not(.fragment-intro, .fragment-hinge) {
  max-width: 760px;
  margin-bottom: 2.25em;
}

.reader-body .reader-opening {
  margin-bottom: 1.6em;
  font-size: 24px;
  line-height: 1.48;
}

.reader-body .reader-opening::first-letter {
  float: left;
  margin: .05em .12em 0 0;
  font-size: 4.2em;
  line-height: .72;
}

.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 72px;
  padding-top: 20px;
  border-top: 1px solid #17151233;
  font: 700 10px/1 "Courier New", monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.reader-open .night-exit {
  opacity: 0;
  pointer-events: none;
}

::view-transition-group(writing-surface) {
  z-index: 100;
  animation-duration: 680ms;
  animation-timing-function: cubic-bezier(.22, .78, .22, 1);
}

::view-transition-old(writing-surface),
::view-transition-new(writing-surface) {
  height: 100%;
  mix-blend-mode: normal;
}

.night-exit {
  position: fixed;
  z-index: 5;
  top: 24px;
  left: 28px;
  padding: 12px 14px;
  border: 1px solid #ffffff55;
  background: #0000004d;
  color: #fff;
  font: 700 12px/1 "Courier New", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.night-exit:hover,
.night-exit:focus-visible {
  border-color: #fff;
  background: #00000080;
  outline: none;
}

@media (max-width: 760px) {
  :root {
    --nav-height: 96px;
  }

  .site-nav {
    align-items: flex-start;
    padding: 15px 18px;
  }

  .site-nav nav {
    max-width: 65%;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 16px;
  }

  .site-nav nav a {
    font-size: 7px;
  }

  .writing-landing {
    grid-template-columns: 1fr;
  }

  .landing-intro {
    top: 125px;
  }

  .landing-intro h1 {
    font-size: 48px;
  }

  .portal {
    min-height: 78svh;
  }

  .portal-copy,
  .portal-haiku .portal-copy {
    top: 38%;
    left: 8%;
  }

  .moon-trigger {
    top: 7.1%;
    left: 7.8%;
    width: 19.5%;
  }

  .night-exit {
    top: 16px;
    left: 16px;
  }

  .encounter-one {
    top: 64%;
    left: 5%;
  }

  .encounter-two {
    top: 25%;
    right: 2%;
  }

  .encounter-three {
    top: 75%;
    left: 12%;
  }

  .encounter-four {
    top: 39%;
    left: 4%;
  }

  .encounter-five {
    top: 67%;
    right: 2%;
  }

  .encounter-six {
    top: 18%;
    left: 10%;
  }

  .encounter-seven {
    top: 52%;
    right: 1%;
  }

  .encounter-eight {
    top: 12%;
    left: 3%;
  }

  .encounter-nine {
    top: 30%;
    right: 2%;
  }

  .encounter-ten {
    top: 65%;
    left: 8%;
  }

  .encounter-eleven {
    top: 20%;
    right: 2%;
  }

  .encounter-twelve {
    top: 47%;
    left: 4%;
  }

  .encounter-trigger {
    grid-template-columns: 23px 38px max-content;
    padding: 12px;
  }

  .encounter-leader {
    width: 32px;
  }

  .encounter-copy {
    min-width: 205px;
    max-width: 240px;
  }

  .encounter-copy strong {
    font-size: 25px;
  }

  .encounter-copy small,
  .encounter-number {
    font-size: 10px;
  }

  .encounter.align-left .encounter-trigger {
    grid-template-columns: max-content 38px 23px;
  }

  .encounter-preview {
    left: 55px;
    width: min(285px, 78vw);
  }

  .encounter.align-left .encounter-preview {
    right: 55px;
    left: auto;
  }

  .lunar-scroll-cue {
    top: 16%;
    left: 50%;
  }

  .reader-surface {
    width: 100%;
    clip-path: polygon(0 12px, calc(100% - 16px) 0, 100% calc(100% - 14px), 10px 100%);
  }

  .reader-surface::before,
  .reader-surface::after {
    display: none;
  }

  .reader-inner {
    padding: 28px 27px 80px;
  }

  .reader-return.reader-close {
    top: 14px;
    right: 44px;
    left: auto;
    width: 58px;
    height: 58px;
    font-size: 46px;
    line-height: 51px;
  }

  .reader-header {
    padding-top: 68px;
  }

  .reader-header h2 {
    font-size: 48px;
  }

  .reader-body {
    font-size: 18px;
    line-height: 1.68;
  }

  .reader-body .reader-opening {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lunar-background,
  .encounter,
  .encounter-node,
  .encounter-leader,
  .encounter-preview,
  .encounter-preview span,
  .encounter-preview em {
    transition: none;
  }

  ::view-transition-group(writing-surface) {
    animation-duration: 1ms;
  }
}
