:root {
  --ink: #141414;
  --paper: #ecebe6;
  --soft: #66645e;
  --line: #c8c6bf;

  --font: "Schibsted Grotesk", "Helvetica Neue", sans-serif;
  --text-s: 13px;
  --text-m: 17px;
  --text-l: 24px;
  --title-size: 42px;

  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-6: 48px;
  --space-8: 64px;
  --space-12: 96px;
  --space-16: 128px;

  --gutter: var(--space-6);
  --side-w: calc(132px + 2 * var(--gutter) + 1px);
  --cover-h: calc(100vh - 2 * var(--gutter) - var(--space-4) - var(--space-6));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: var(--text-m)/1.5 var(--font);
}

a { color: inherit; text-decoration: none; }

.wrap { margin-inline: var(--gutter); }

.title {
  font-size: var(--title-size);
  font-weight: 800;
  letter-spacing: .02em;
  line-height: .95;
  text-transform: uppercase;
}

.title span { display: block; }

.label,
.small { font-size: var(--text-s); }

.label {
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.small { color: var(--soft); }

.logo {
  display: block;
  overflow: visible;
}

.logo text {
  font: 800 19px var(--font);
  fill: currentColor;
}

.side {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: var(--side-w);
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: var(--gutter);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-s);
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1;
  text-transform: uppercase;
}

.nav button,
.menu-links button {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.nav a,
.nav button {
  color: var(--soft);
  transition: color .2s;
}

.nav a:hover,
.nav button:hover,
.nav a[aria-current] { color: var(--ink); }

.side-foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: auto;
}

.side-foot a:hover { color: var(--ink); }

.shelf {
  container-type: inline-size;
  overflow: clip;
}

.track {
  display: flex;
  height: 100vh;
  overflow-x: auto;
  padding: var(--gutter);
}

.book {
  flex: none;
  display: flex;
  flex-direction: column;
}

.head {
  display: flex;
  gap: var(--space-3);
  height: var(--space-4);
  margin-bottom: var(--space-6);
  line-height: 1;
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
  padding: var(--space-2) 0 0 var(--space-2);
}

.head span + span { color: var(--soft); }

.run {
  display: flex;
  gap: var(--space-3);
}

.row {
  display: flex;
  gap: var(--space-8);
  padding-right: var(--space-16);
}

.book:last-child .row { padding-right: 0; }

.cover {
  display: block;
  flex: none;
  width: calc(var(--cover-h) * 1549 / 2540);
  height: var(--cover-h);
  aspect-ratio: 1549 / 2540;
  object-fit: cover;
  box-shadow: 0 var(--space-4) var(--space-6) calc(var(--space-4) * -1) rgba(0, 0, 0, .5);
}

.cover--soon {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-4) var(--space-3);
  background: var(--cover, var(--ink));
  color: var(--paper);
  line-height: 1.2;
}

.cover--soon span { font-size: 5cqw; }

.cover--soon strong {
  font-size: 12cqw;
  font-weight: 800;
  line-height: .95;
}

.info {
  flex: 0 0 560px;
  display: flex;
  flex-direction: column;
}

.intro {
  max-width: 400px;
  margin-top: var(--space-4);
}

.quotes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-4);
  margin-top: var(--space-6);
}

.quotes + .quotes { margin-top: var(--space-3); }

.quotes cite {
  display: block;
  margin-top: var(--space-1);
  font-style: normal;
}

.end {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-6);
}

.btn {
  display: inline-block;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-2) var(--space-3);
  font-weight: 700;
  line-height: 1;
}

.btn:hover { background: #3d3c38; }

.about {
  inset: 0 0 0 var(--side-w);
  width: auto;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: var(--gutter);
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  box-shadow: calc(var(--space-4) * -1) 0 var(--space-8) rgba(0, 0, 0, .12);
  translate: 100% 0;
  transition: translate .6s cubic-bezier(.2, .7, .2, 1), display .6s allow-discrete, overlay .6s allow-discrete;
}

.about:popover-open {
  display: flex;
  flex-direction: column;
  translate: 0 0;
}

@starting-style {
  .about:popover-open { translate: 100% 0; }
}

.close {
  margin-left: auto;
  border: 0;
  white-space: nowrap;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.contacts { margin-top: auto; }

.contacts div {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: baseline;
  border-top: 1px solid var(--ink);
  padding-block: var(--space-2);
}

.progress { display: none; }

.line { border-bottom: 1px solid currentColor; }
.line:hover { border-color: transparent; }

.menu-btn {
  display: none;
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

.menu-btn svg { display: block; }

.menu {
  inset: 0 0 0 auto;
  width: min(320px, 85vw);
  height: 100%;
  max-height: none;
  margin: 0;
  border: 0;
  border-left: 1px solid var(--ink);
  padding: 0 var(--gutter);
  background: var(--paper);
  color: var(--ink);
  translate: 100% 0;
  transition: translate .5s cubic-bezier(.2, .7, .2, 1), display .5s allow-discrete, overlay .5s allow-discrete;
}

.menu::backdrop {
  background: rgba(20, 20, 20, 0);
  transition: background .5s, display .5s allow-discrete, overlay .5s allow-discrete;
}

.menu:popover-open {
  display: flex;
  flex-direction: column;
  translate: 0 0;
}

.menu:popover-open::backdrop { background: rgba(20, 20, 20, .25); }

@starting-style {
  .menu:popover-open { translate: 100% 0; }
  .menu:popover-open::backdrop { background: rgba(20, 20, 20, 0); }
}

.menu-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: calc(42px + 2 * var(--space-3));
}

.menu-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  margin-top: var(--space-6);
  border-top: 1px solid var(--ink);
  padding-top: var(--space-4);
}

.menu-links button { color: var(--soft); }

.menu-foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: auto;
  border-top: 1px solid var(--ink);
  padding-block: var(--space-3) var(--space-6);
}

@supports (animation-timeline: scroll()) {
  @media (min-width: 801px) {
    .home .shelf { height: calc(var(--n, 4) * 100vh); }

    .home .track {
      position: sticky;
      top: 0;
      width: max-content;
      overflow: visible;
      animation: slide linear both;
      animation-timeline: scroll();
    }

    .home .side::after {
      content: "";
      position: absolute;
      top: 0;
      right: -1px;
      width: 1px;
      height: 100%;
      background: var(--ink);
      transform-origin: top;
      animation: grow linear both;
      animation-timeline: scroll();
    }
  }
}

@keyframes slide { to { transform: translateX(calc(100cqw - 100%)); } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes page-in { from { opacity: 0; translate: calc(var(--space-6) * var(--i, 1)) 0; } }
@keyframes turn {
  0% { transform: perspective(900px) rotateY(-18deg); }
  40%, 65% { transform: none; }
  100% { transform: perspective(900px) rotateY(18deg); }
}

@media (max-width: 800px) {
  :root { --title-size: 36px; --gutter: var(--space-3); --page: calc(100cqw - 3 * var(--gutter)); }
  body { grid-template-columns: 1fr auto; grid-template-rows: auto minmax(0, 1fr) auto; align-items: center; }
  .home { height: 100svh; min-height: 0; timeline-scope: --pages; }
  .side { display: contents; }
  .side .nav, .side-foot { display: none; }
  .home-link { padding: var(--space-3) var(--gutter); }
  .menu-btn { display: block; }
  .side .menu-btn { margin-right: var(--gutter); }
  .shelf { grid-column: 1 / -1; grid-row: 2; align-self: stretch; }
  .track { height: 100%; gap: var(--gutter); padding: 0 calc(100cqw - var(--page) - var(--gutter)) var(--space-3) var(--gutter); overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scroll-behavior: smooth; scrollbar-width: none; scroll-timeline: --pages inline; }
  .head { height: auto; margin-bottom: var(--space-3); }
  .run { position: sticky; left: var(--space-2); }
  .book .row { flex: 1; min-height: 0; display: grid; grid-auto-flow: column; grid-auto-columns: var(--page); grid-template-rows: minmax(0, 1fr) auto; gap: var(--space-3) var(--gutter); padding-right: 0; }
  .book .info { display: contents; }
  .book .cover { grid-area: 1 / 1; width: auto; max-width: 100%; height: 100%; }
  .book .title { grid-area: 2 / 1; }
  .book .intro { grid-area: 1 / 2; max-width: none; margin-top: 0; font-size: var(--text-l); line-height: 1.35; }
  .book .end { grid-area: 2 / 2; flex-direction: column; align-items: flex-start; padding-top: 0; }
  .book .quotes { grid-row: 1 / 3; grid-template-columns: 1fr; align-content: start; margin-top: 0; }
  .book .cover, .book .intro, .book .quotes { scroll-snap-align: start; scroll-snap-stop: always; }
  .progress { grid-column: 1 / -1; grid-row: 3; position: relative; display: block; height: var(--space-6); margin-inline: var(--gutter); border-top: 1px solid var(--line); }
  .progress::before { content: ""; position: absolute; inset: -1px 0 auto; height: 1px; background: var(--ink); transform-origin: left; animation: grow-x linear both; animation-timeline: --pages; }
  .about { inset: 0; padding: var(--gutter) 0 var(--space-3); overflow: hidden; }
  .about .head { margin-inline: var(--gutter); }
  .about .head span + span { display: none; }
  .about .row { flex: 1; min-height: 0; display: grid; grid-auto-flow: column; grid-auto-columns: var(--page); grid-template-rows: minmax(0, 1fr) auto; gap: var(--space-3) var(--gutter); padding: 0 calc(100cqw - var(--page) - var(--gutter)) 0 var(--gutter); overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: none; }
  .about .info { display: contents; }
  .about .cover { grid-area: 1 / 1; width: auto; max-width: 100%; height: 100%; }
  .about .title { grid-area: 2 / 1; }
  .about .intro { grid-area: 1 / 2 / 3; max-width: none; margin-top: 0; }
  .about .contacts { grid-area: 1 / 3 / 3; margin-top: 0; }
  .about .contacts div { grid-template-columns: 1fr; row-gap: var(--space-1); padding-block: var(--space-3); }
  .about .contacts dd { font-size: var(--text-l); overflow-wrap: anywhere; }
  .about .cover, .about .intro, .about .contacts { scroll-snap-align: start; scroll-snap-stop: always; }
}

@media (max-width: 800px) and (prefers-reduced-motion: no-preference) {
  .book .title, .book .intro, .book .end, .book blockquote,
  .about .title, .about .intro, .about .contacts {
    animation: page-in linear both;
    animation-timeline: view(inline);
    animation-range: entry 0% entry 100%;
  }

  .book blockquote:nth-child(2) { --i: 2; }
  .book blockquote:nth-child(3) { --i: 3; }
  .book blockquote:nth-child(4) { --i: 4; }

  .book .cover, .about .cover {
    transform-origin: left center;
    animation: turn linear both;
    animation-timeline: view(inline);
    animation-range: cover;
  }
}
