/* Commonplace — editorial paper, rooms, and quiet type. */

:root {
  --paper: #f3ead7;
  --paper-warm: #fbf4e6;
  --ink: #191713;
  --muted: #756b5f;
  --line: #d4c3a7;
  --blue: #154f65;
  --red: #b74735;
  --gold: #d79b2d;
  --green: #687d50;
  --shadow: rgba(44, 33, 22, 0.16);
  --display: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --body: "Iowan Old Style", Palatino, Georgia, serif;
  --label: ui-monospace, "SF Mono", Menlo, "Cascadia Mono", Consolas, monospace;
  --room: url("assets/apartment.png");
  --measure: 34rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  background:
    linear-gradient(90deg, rgba(25, 23, 19, 0.045) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(180deg, var(--paper-warm) 0%, var(--paper) 100%);
  overflow-wrap: break-word;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.3;
  background-image: radial-gradient(rgba(25, 23, 19, 0.2) 0.55px, transparent 0.55px);
  background-size: 12px 12px;
}

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

button {
  font: inherit;
}

a {
  color: inherit;
}

.skip {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 40;
  transform: translateY(-200%);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ink);
  background: var(--paper-warm);
  color: var(--ink);
  font-family: var(--label);
  font-size: 0.8rem;
  text-decoration: none;
}

.skip:focus {
  transform: none;
}

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

/* Fixed wordmark — arrives after the opening, leaves before the close. */
.wordmark {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 22;
  padding: 0.85rem clamp(1rem, 3vw, 2.2rem);
  color: rgba(25, 23, 19, 0.7);
  font-family: var(--label);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  mix-blend-mode: multiply;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-110%);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

body.in-tour .wordmark {
  opacity: 1;
  transform: none;
}

/* ——— Opening ——— */
.opening {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 92svh;
  display: grid;
  align-items: end;
  padding: 5.75rem clamp(1.1rem, 4vw, 3.2rem) 2.2rem;
}

.opening__inner {
  position: relative;
  z-index: 2;
  width: min(1480px, 100%);
  margin: 0 auto;
  min-height: min(640px, 72svh);
  display: grid;
  align-items: end;
}

.opening__copy {
  max-width: 42rem;
}

.kicker {
  margin: 0 0 0.85rem;
  color: var(--red);
  font-family: var(--label);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  max-width: 12ch;
  margin: 0 0 1.15rem;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: clamp(3.6rem, 11vw, 7rem);
  font-weight: 460;
  line-height: 0.88;
  letter-spacing: -0.01em;
}

.lede {
  max-width: 36rem;
  margin: 0;
  color: #4a433a;
  font-size: clamp(1.05rem, 1.6vw, 1.28rem);
  line-height: 1.52;
}

.opening::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.14;
  mix-blend-mode: multiply;
  background-image:
    linear-gradient(90deg, #fbf4e6 0%, rgba(251, 244, 230, 0.82) 26%, rgba(251, 244, 230, 0) 58%),
    var(--room);
  background-size: 100% 100%, cover;
  background-position: 0 0, 72% center;
  background-repeat: no-repeat;
  filter: saturate(0.92) contrast(0.96);
}

.hint {
  width: min(1480px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.05rem 0 1.4rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  color: #8a5a48;
  font-family: var(--label);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  transition: opacity 0.55s ease;
}

body.has-moved .hint {
  opacity: 0;
}

.hint::before,
.hint::after {
  content: "";
  width: clamp(1.2rem, 5vw, 3rem);
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(138, 90, 72, 0.5));
}

.hint::after {
  background: linear-gradient(to left, transparent, rgba(138, 90, 72, 0.5));
}

/* ——— Tour: sticky room + tall story ——— */
.tour {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.76fr);
  gap: clamp(1.4rem, 4vw, 4.2rem);
  width: min(1480px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.8rem, 4.5vw, 3.8rem) 0 clamp(3.5rem, 8vw, 7.5rem);
}

.stage {
  position: sticky;
  top: clamp(2.4rem, 6vh, 4.4rem);
  align-self: start;
}

.viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1.58;
  background: #eadcc2;
  border: 1px solid rgba(25, 23, 19, 0.2);
  box-shadow: 0 16px 54px var(--shadow);
}

.viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(251, 244, 230, 0.18);
}

.camera {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
  transition: transform 0.6s cubic-bezier(0.2, 0.78, 0.2, 1);
}

.camera__room,
.camera__spot {
  position: absolute;
  inset: 0;
  background-image: var(--room);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.camera__room {
  filter: brightness(1.03) saturate(1.02) contrast(0.99);
  transition: filter 0.48s ease;
}

.viewport.is-lit .camera__room {
  filter: brightness(0.78) saturate(0.76) contrast(0.98) blur(1.5px);
}

.camera__spot {
  filter: brightness(1.08) saturate(1.06);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.48s ease;
  -webkit-mask-image: radial-gradient(
    ellipse var(--hw, 11%) var(--hh, 18%) at var(--fx, 50%) var(--fy, 50%),
    #000 0 44%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse var(--hw, 11%) var(--hh, 18%) at var(--fx, 50%) var(--fy, 50%),
    #000 0 44%,
    transparent 100%
  );
}

.viewport.is-lit .camera__spot {
  opacity: 1;
}

.dimmer {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #0b0907;
  opacity: var(--veil, 0);
  pointer-events: none;
}

.plaque {
  margin: 0.7rem 0 0;
  color: var(--red);
  font-family: var(--label);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-height: 1.2em;
}

.story {
  min-width: 0;
}

.beat {
  min-height: 78vh;
  display: grid;
  align-content: center;
  padding: clamp(2.8rem, 7vw, 6.2rem) 0;
  border-top: 1px solid var(--line);
}

.beat:focus {
  outline: none;
}

.beat.is-on .beat__title {
  color: var(--blue);
}

.beat__title {
  margin: 0 0 0.78rem;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: 1.25rem;
  font-weight: 520;
  line-height: 1.08;
  transition: color 0.22s ease;
}

.excerpt {
  position: relative;
  margin: 0;
  color: #211e19;
  font-size: 1.56rem;
  line-height: 1.34;
  white-space: pre-line;
  quotes: "“" "”" "‘" "’";
}

.excerpt::before {
  content: open-quote;
  position: absolute;
  transform: translateX(-100%);
  color: var(--red);
}

.excerpt::after {
  content: close-quote;
  color: var(--red);
}

.cite {
  margin: 0.68rem 0 0;
  color: #655749;
  font-family: var(--body);
  font-style: italic;
  font-size: 0.88rem;
  line-height: 1.48;
}

.cite__who {
  font-weight: 600;
  font-style: italic;
  color: #56493c;
}

.cite__who a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(86, 73, 60, 0.24);
  text-underline-offset: 3px;
}

.cite__who a:hover {
  color: var(--blue);
  text-decoration-color: currentColor;
}

.cite__who a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.beat--scene {
  min-height: 56vh;
}

.beat__kicker {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0 0 1.25rem;
  color: var(--accent, var(--red));
  font-family: var(--label);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.beat__kicker::after {
  content: "";
  flex: 1;
  max-width: 5.4rem;
  height: 1px;
  background: color-mix(in srgb, var(--accent, var(--red)) 46%, transparent);
}

.beat__prose {
  max-width: var(--measure);
  margin: 0;
  color: #3c352c;
  font-size: 1.28rem;
  line-height: 1.56;
}

.beat--scene .beat__prose::first-letter,
.afterword__essay p:first-child::first-letter {
  float: left;
  padding: 0.05em 0.12em 0 0;
  color: var(--accent, #5d5348);
  font-family: var(--display);
  font-size: 3.25em;
  font-weight: 500;
  line-height: 0.8;
}

/* ——— Progress ticker ——— */
.ticker {
  position: sticky;
  bottom: 0;
  z-index: 12;
  border-top: 1px solid rgba(25, 23, 19, 0.12);
  background: rgba(251, 244, 230, 0.84);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

body.in-tour .ticker {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.ticker__track {
  position: relative;
  width: min(1480px, calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0.78rem 0;
}

.ticker__track::before,
.ticker__track::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  pointer-events: none;
}

.ticker__track::before {
  right: 0;
  background: rgba(25, 23, 19, 0.15);
}

.ticker__track::after {
  width: var(--progress, 0%);
  background: var(--progress-color, var(--red));
  transition: width 0.24s ease, background 0.24s ease;
}

.tick {
  flex: 1 1 0;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tick.room-gap {
  margin-left: clamp(0.75rem, 2.4vw, 1.9rem);
}

.tick::before {
  content: "";
  width: 2px;
  height: 0.48rem;
  border-radius: 1px;
  background: color-mix(in srgb, var(--accent, #191713) 34%, transparent);
  transition: height 0.18s ease, width 0.18s ease, background 0.18s ease, border-radius 0.18s ease;
}

.tick:hover::before {
  height: 0.78rem;
  background: color-mix(in srgb, var(--accent, #191713) 64%, transparent);
}

.tick.is-on::before {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent, var(--red));
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--accent, var(--red)) 16%, transparent);
}

.tick:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

/* ——— Close ——— */
.afterword {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2.4rem, 5vw, 4rem) 0 clamp(2.6rem, 5.5vw, 4.4rem);
}

.afterword__rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: clamp(2.2rem, 5vw, 3.4rem);
}

.afterword__rule::before,
.afterword__rule::after {
  content: "";
  width: clamp(2.8rem, 9vw, 5.8rem);
  height: 1px;
}

.afterword__rule::before {
  background: linear-gradient(to right, transparent, var(--line));
}

.afterword__rule::after {
  background: linear-gradient(to left, transparent, var(--line));
}

.afterword__rule span {
  width: 0.4rem;
  height: 0.4rem;
  transform: rotate(45deg);
  border: 1px solid #8a6110;
}

.afterword__essay {
  --accent: #5d5348;
  max-width: 32rem;
  margin: 0 auto;
  display: grid;
  gap: 1.45rem;
  color: #3c352c;
  font-size: 1.24rem;
  line-height: 1.58;
}

.afterword__essay p {
  margin: 0;
}

.bibliography {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.4rem 0 2rem;
}

.bibliography h2 {
  margin: 0 0 1rem;
  color: #756b5f;
  font-family: var(--label);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.bibliography ol {
  max-width: 46rem;
  margin: 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
  display: grid;
  gap: 0.55rem;
  color: #655749;
  font-size: 0.9rem;
  line-height: 1.5;
}

.bibliography li {
  padding-left: 0;
}

.bib-label {
  display: inline-block;
  min-width: 11.5rem;
  margin-right: 0.45rem;
  color: #56493c;
  font-family: var(--label);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bibliography a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(101, 87, 73, 0.42);
  text-underline-offset: 2px;
}

.bibliography a:hover {
  color: var(--blue);
  text-decoration-color: currentColor;
}

.bibliography a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.colophon {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.6rem 0 2.2rem;
  color: #a89c8a;
  font-family: var(--label);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

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

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

  .camera,
  .camera__room,
  .camera__spot,
  .beat__title,
  .hint,
  .wordmark,
  .ticker,
  .ticker__track::after,
  .tick::before {
    transition: none;
  }
}

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

  .opening {
    min-height: auto;
    padding-top: 4.8rem;
  }

  .wordmark {
    display: none;
  }

  .stage {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 0.35rem 0 0.65rem;
    background: var(--paper-warm);
    box-shadow: 0 0.55rem 0.85rem -0.45rem var(--shadow);
  }

  .viewport {
    aspect-ratio: 1.58;
  }

  .beat {
    min-height: 66vh;
    padding: 1.6rem 0;
  }

  .beat--scene {
    min-height: 46vh;
  }
}

@media (max-width: 720px) {
  .opening {
    min-height: calc(100svh - 4.6rem);
    padding: 2rem 1rem 1rem;
  }

  h1 {
    font-size: 3.9rem;
    line-height: 0.92;
  }

  .opening::after {
    background-image:
      linear-gradient(180deg, rgba(251, 244, 230, 0.12), rgba(251, 244, 230, 0) 28%, rgba(251, 244, 230, 0.86) 78%),
      var(--room);
    background-position: 0 0, 58% center;
  }

  .tour {
    width: 100%;
    padding-top: 0.8rem;
  }

  .story {
    width: calc(100% - 2rem);
    margin-inline: auto;
  }

  .viewport {
    border-left: 0;
    border-right: 0;
  }

  .plaque {
    display: none;
  }

  .beat__title {
    font-size: 1.12rem;
  }

  .excerpt {
    font-size: 1.36rem;
  }

  .beat__prose,
  .afterword__essay {
    font-size: 1.08rem;
  }

  .ticker {
    padding-inline: 0.4rem;
  }

  .bib-label {
    display: block;
    margin-bottom: 0.15rem;
  }
}
