:root {
  --ink: #0a0a0a;
  --paper: #f4f4f4;
  --mute: #5a5a5a;
  --line: #0a0a0a;
  --serif: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mast: 4.25rem;
  --ease: cubic-bezier(0.77, 0, 0.18, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
}

body:not(.is-open) {
  overflow: hidden;
  height: 100svh;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  width: 100%;
  height: 2px;
  background: transparent;
  pointer-events: none;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  transform-origin: left center;
}

body.is-open .progress span {
  background: var(--ink);
}

.piano ~ .chapter .progress,
body:has(.piano.is-here) .progress span {
  background: var(--paper);
}

/* Gate */
.gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.gate__door {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 50.2%;
  background: var(--ink);
  z-index: 81;
  transition: transform 1.15s var(--ease);
}

.gate__door--left {
  left: 0;
}

.gate__door--right {
  right: 0;
}

.gate.is-open .gate__door--left {
  transform: translateX(-100%);
}

.gate.is-open .gate__door--right {
  transform: translateX(100%);
}

.gate.is-done {
  visibility: hidden;
}

.gate__enter {
  position: fixed;
  inset: 0;
  z-index: 82;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  width: 100%;
  padding: 2rem 8vw;
  color: #f4f4f4;
  text-align: center;
  transition: opacity 0.4s var(--ease), visibility 0.4s var(--ease);
}

.gate.is-open .gate__enter {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate__ready,
.gate__ask {
  opacity: 0;
}

.gate__ready {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.gate__ask {
  font-family: var(--sans);
  font-size: clamp(2.8rem, 8vw, 5.6rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.line {
  position: absolute;
  background: #f4f4f4;
  transform-origin: center;
  opacity: 0;
}

.line--v {
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
  transform: scaleY(0);
}

.line--h {
  left: 8vw;
  right: 8vw;
  top: 38%;
  height: 1px;
  transform: scaleX(0);
}

.line--top,
.line--bottom {
  left: 8vw;
  right: 8vw;
  height: 1px;
  transform: scaleX(0);
}

.line--top {
  top: 7vh;
}

.line--bottom {
  bottom: 7vh;
}

.line--under {
  left: 50%;
  top: calc(50% + 4.4rem);
  width: min(18rem, 46vw);
  height: 1px;
  margin-left: min(-9rem, -23vw);
  transform: scaleX(0);
}

.gate.is-ready .line--v {
  animation: draw-y 0.9s var(--ease) 0.05s forwards, line-hold 1.2s linear 1s forwards;
}

.gate.is-ready .line--h {
  animation: draw-x 0.85s var(--ease) 0.35s forwards, fade-line 0.5s ease 1.15s forwards;
}

.gate.is-ready .line--top {
  animation: draw-x 0.8s var(--ease) 0.7s forwards;
}

.gate.is-ready .line--bottom {
  animation: draw-x 0.8s var(--ease) 0.85s forwards;
}

.gate.is-ready .line--under {
  animation: draw-x 0.7s var(--ease) 1.05s forwards;
}

.gate.is-ready .gate__ready,
.gate.is-ready .gate__ask {
  animation: rise 0.9s var(--ease) 0.55s both;
}

.gate.is-ready .gate__ask {
  animation-delay: 0.72s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes draw-y {
  from {
    opacity: 1;
    transform: scaleY(0);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes draw-x {
  from {
    opacity: 1;
    transform: scaleX(0);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes fade-line {
  to {
    opacity: 0.18;
  }
}

@keyframes line-hold {
  to {
    opacity: 0;
  }
}

/* Mast */
.mast {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--mast);
  padding: 0 1.5rem;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.mast__name {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.mast__social {
  display: flex;
  justify-content: flex-end;
  gap: 0.85rem;
}

.mast__social a {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
}

.mast__social svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.mast__social a:hover,
.mast__social a:focus-visible {
  opacity: 0.55;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(20rem, 0.95fr);
  min-height: calc(100svh - var(--mast));
  border-bottom: 1px solid var(--ink);
}

.hero__copy {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(2rem, 5vw, 4.5rem);
  padding-bottom: clamp(2.5rem, 7vw, 5rem);
}

.hero h1 {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(3.6rem, 8vw, 6.4rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.hero__lead {
  max-width: 34rem;
  margin: 1.75rem 0 0;
  font-size: 1.12rem;
  font-weight: 400;
}

.hero__place {
  margin: 1.5rem 0 0;
  color: var(--mute);
  font-size: 0.95rem;
}

.hero__figure {
  margin: 0;
  border-left: 1px solid var(--ink);
  overflow: hidden;
  background: #d8d4ce;
}

.hero__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  filter: grayscale(1) contrast(1.04);
}

/* Rail */
.rail {
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.rail p {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.75rem;
  margin: 0;
  padding: 0.95rem 1.5rem;
  font-size: 0.92rem;
}

.rail span {
  white-space: nowrap;
}

.rail span + span::before {
  content: "/";
  margin-right: 1.75rem;
}

/* Chapters */
.chapter {
  display: grid;
  grid-template-columns: minmax(6rem, 14rem) minmax(0, 42rem);
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(4.5rem, 10vw, 8rem) clamp(1.5rem, 5vw, 4.5rem);
  border-bottom: 1px solid var(--ink);
}

.chapter__mark {
  font-family: var(--sans);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
}

.mark {
  display: block;
  width: 4.5rem;
  height: auto;
  filter: grayscale(1);
}

.group {
  padding: clamp(3.5rem, 8vw, 6rem) clamp(1.5rem, 5vw, 4.5rem);
  border-bottom: 1px solid var(--ink);
}

.group h2 {
  margin: 0 0 1.75rem;
  max-width: none;
  font-size: clamp(2rem, 4vw, 3rem);
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 46rem;
}

.items li {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1.15rem 0;
  border-top: 1px solid var(--ink);
}

.items h3 {
  margin: 0.15rem 0 0.3rem;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.items p {
  margin: 0;
  max-width: 38rem;
  color: var(--ink);
  font-size: 0.98rem;
}

.icon {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: contain;
  filter: grayscale(1) contrast(1.05);
}

.icon--plate {
  object-fit: cover;
  background: #0a0a0a;
}

.chapter h2,
.split h2,
.piano h2,
.close h2 {
  margin: 0 0 1.25rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2rem, 4.4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.chapter p,
.split p,
.piano p {
  margin: 0 0 1.1rem;
  max-width: 40rem;
}

.chapter p:last-child {
  margin-bottom: 0;
}

.chapter__link a {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
}

.chapter__link a:hover,
.chapter__link a:focus-visible {
  opacity: 0.55;
}

/* Lab split */
.split {
  display: grid;
  grid-template-columns: minmax(16rem, 0.85fr) minmax(0, 1.15fr);
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
}

.split__sticky {
  position: sticky;
  top: var(--mast);
  align-self: start;
  min-height: calc(100svh - var(--mast));
  padding: clamp(2rem, 5vw, 4rem);
  border-right: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.split__index,
.piano__index {
  margin: 0 0 1rem;
  font-family: var(--sans);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
}

.split h2,
.piano h2 {
  margin-bottom: 1rem;
}

.split__notes article {
  min-height: 72vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2.5rem, 6vw, 5rem);
  border-bottom: 1px solid var(--ink);
}

.split__notes article:last-child {
  border-bottom: 0;
}

.split h3 {
  margin: 0 0 0.9rem;
  font-family: var(--sans);
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.split em {
  font-family: var(--sans);
  font-style: italic;
}

/* Piano */
.piano {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.piano__inner {
  padding: clamp(4.5rem, 10vw, 8rem) clamp(1.5rem, 5vw, 4.5rem);
  max-width: 68rem;
}

.piano__lead {
  max-width: 36rem;
  font-size: 1.2rem;
}

.piano__facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(244, 244, 244, 0.35);
}

.piano__facts p {
  margin: 0;
  font-size: 1rem;
}

/* Close */
.close {
  padding: clamp(5rem, 12vw, 9rem) clamp(1.5rem, 5vw, 4.5rem) 4rem;
}

.close h2 {
  font-size: clamp(2.8rem, 8vw, 5.4rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  margin-bottom: 0.6rem;
}

.close p {
  margin: 0;
  font-size: 1.15rem;
}

.close__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-top: 2.5rem;
}

.close__links a {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
}

.close__links a:hover,
.close__links a:focus-visible {
  opacity: 0.55;
}

/* Reveal */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  animation: rise 0.9s var(--ease) forwards;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero__figure {
    order: -1;
    border-left: 0;
    border-bottom: 1px solid var(--ink);
    height: 68svh;
    min-height: 24rem;
  }

  .chapter {
    grid-template-columns: 1fr;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .split__sticky {
    position: relative;
    top: 0;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .split__notes article {
    min-height: 0;
  }

  .piano__facts {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .gate.is-ready .gate__ready,
  .gate.is-ready .gate__ask {
    animation: none;
    opacity: 1;
  }

  .line {
    display: none;
  }

  .gate__door {
    transition: none;
  }

  .hero__figure img {
    transform: none;
  }
}
