
:root {
  --paper: #F3EEE2;
  --paper2: #E9E2D1;
  --ink: #1B1714;
  --mute: #5B5249;
  --cobalt: #2236D1;
  --on-cobalt: #fff;
  --line: #1B171433;
  --err: #9B1C1C;
  --ok: #1F5E3A;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17120F;
    --paper2: #221B16;
    --ink: #F1EADB;
    --mute: #B5AA9A;
    --cobalt: #8EA0FF;
    --on-cobalt: #10143A;
    --line: #F1EADB33;
    --err: #FF9A9A;
    --ok: #8FD6A8;
  }
}

:root[data-theme="dark"] {
  --paper: #17120F;
  --paper2: #221B16;
  --ink: #F1EADB;
  --mute: #B5AA9A;
  --cobalt: #8EA0FF;
  --on-cobalt: #10143A;
  --line: #F1EADB33;
  --err: #FF9A9A;
  --ok: #8FD6A8;
}

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

html {
  height: auto;
  scroll-padding-top: env(safe-area-inset-top, 0px);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  background: var(--paper);
  z-index: 10;
}

h1, h2, h3 {
  font-family: var(--serif);
  line-height: 1.05;
  margin: 0;
  font-weight: 700;
  letter-spacing: -.02em;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

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

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: var(--paper);
  padding: .6rem 1rem;
  z-index: 20;
}

.skip:focus {
  top: 1rem;
}

/* Navigation */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 0;
}

.mark {
  font: italic 700 1.25rem var(--serif);
  text-decoration: none;
  letter-spacing: -.01em;
}

.nav div {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.nav a.lk {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}

.nav a.lk:hover {
  border-color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: .7rem 1.4rem;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: 600 1rem var(--sans);
  text-decoration: none;
  cursor: pointer;
  border-radius: 999px;
  transition: background .2s, color .2s;
}

.btn:hover {
  background: var(--cobalt);
  border-color: var(--cobalt);
  color: var(--on-cobalt);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
}

.btn.ghost:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn[disabled] {
  opacity: .6;
  cursor: progress;
}

/* Hero */
.hero {
  padding: 2rem 0 3rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-style: italic;
  font-family: var(--serif);
  color: var(--mute);
}

.dot {
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  background: var(--cobalt);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: .25;
    transform: scale(.7);
  }
}

.hero h1 {
  font-size: clamp(3rem, 12vw, 8.5rem);
  margin: 1rem 0 1.5rem;
  max-width: 12ch;
}

.hero h1 em {
  font-weight: 400;
}

.lede {
  max-width: 34rem;
  font-size: 1.2rem;
  color: var(--mute);
}

.signup {
  margin-top: 1.75rem;
  max-width: 36rem;
}

.row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.row input {
  flex: 1 1 15rem;
  min-height: 48px;
  padding: .7rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.msg {
  min-height: 1.6rem;
  margin-top: .6rem;
  font-size: .97rem;
}

.msg.err {
  color: var(--err);
}

.msg.ok {
  color: var(--ok);
}

.fine {
  font-size: .88rem;
  color: var(--mute);
  margin-top: .3rem;
}

.cta2 {
  margin-top: 1rem;
}

/* Bookshelf */
.shelf {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  margin-top: 3rem;
  padding: 0 1.25rem;
  border-bottom: 10px solid var(--ink);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.shelf::-webkit-scrollbar {
  display: none;
}

.spine {
  flex: 0 0 auto;
  writing-mode: vertical-rl;
  padding: 1rem .55rem;
  font: 700 1rem var(--serif);
  border: 0;
  color: #F6F0E2;
  cursor: pointer;
  border-radius: 3px 3px 0 0;
  transition: transform .25s;
  min-width: 44px;
  text-align: left;
}

.spine:hover,
.spine:focus-visible {
  transform: translateY(-14px);
}

.spine small {
  font: 400 .75rem var(--sans);
  opacity: .8;
  margin-top: .8rem;
}

.shelf-note {
  max-width: 72rem;
  margin: .6rem auto 0;
  padding: 0 1.25rem;
  font-size: .85rem;
  color: var(--mute);
}

/* Sections */
section {
  padding: 4.5rem 0;
}

.tint {
  background: var(--paper2);
}

.ch {
  font: italic 400 1rem var(--serif);
  color: var(--mute);
  margin-bottom: .8rem;
  display: block;
}

h2 {
  font-size: clamp(2rem, 6vw, 3.6rem);
  max-width: 18ch;
}

.sub {
  margin-top: 1rem;
  max-width: 38rem;
  color: var(--mute);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 2rem 0 1.5rem;
}

.chip {
  min-height: 44px;
  padding: .5rem 1.1rem;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  font: 600 .95rem var(--sans);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 1.5rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.book {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.book:nth-child(3n+2) {
  margin-top: 1.6rem;
}

.cover {
  aspect-ratio: 2 / 3;
  padding: 1rem .9rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #F6F0E2;
  border-radius: 2px 8px 8px 2px;
  box-shadow: inset 6px 0 0 #0003, 5px 6px 0 var(--line);
  transition: transform .3s;
}

.book:hover .cover {
  transform: rotate(-2deg) translateY(-4px);
}

.cover b {
  font: 700 1.3rem/1.05 var(--serif);
}

.cover span {
  font-size: .78rem;
  opacity: .85;
}

.cap {
  font: italic 400 .95rem/1.4 var(--serif);
  color: var(--mute);
}

/* Benefits */
.ben {
  display: grid;
  gap: 0;
  margin-top: 2.5rem;
  border-top: 2px solid var(--ink);
}

.ben article {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: .5rem;
}

.ben h3 {
  font-size: 1.7rem;
}

.ben p {
  color: var(--mute);
  max-width: 36rem;
}

/* Margin notes */
.notes {
  position: relative;
  display: grid;
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.note {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1.2rem 1.3rem;
  max-width: 26rem;
  font: italic 400 1.15rem/1.4 var(--serif);
}

.note i {
  display: block;
  margin-top: .6rem;
  font: 400 .85rem var(--sans);
  color: var(--mute);
}

.note.hand {
  border: 0;
  border-left: 3px solid var(--cobalt);
  background: transparent;
  padding-left: 1rem;
  transform: rotate(-1.2deg);
}

.disc {
  margin-top: 1.5rem;
  font-size: .88rem;
  color: var(--mute);
}

/* Closing section */
.close {
  text-align: center;
}

.close h2 {
  margin: 0 auto;
  max-width: 14ch;
}

.close .signup {
  margin: 2rem auto 0;
  text-align: left;
}

.sign {
  margin-top: 3rem;
  font: italic 400 1.1rem var(--serif);
  color: var(--mute);
}

footer {
  padding: 2rem 0 3rem;
  font-size: .9rem;
  color: var(--mute);
  text-align: center;
}

/* Tablet and desktop */
@media (min-width: 48rem) {
  .wrap,
  .shelf,
  .shelf-note {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }

  .ben article {
    grid-template-columns: 1fr 1.4fr;
    gap: 2rem;
    align-items: baseline;
  }

  .notes {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
  }

  .note:nth-child(2) {
    margin-top: 2.5rem;
  }

  .note:nth-child(3) {
    margin-top: .8rem;
  }

  .shelf {
    justify-content: center;
    max-width: none;
  }
}

/* Entrance animations */
@media (prefers-reduced-motion: no-preference) {
  .hero h1,
  .hero .lede,
  .hero .signup {
    animation: rise .9s cubic-bezier(.2, .7, .2, 1) both;
  }

  .hero .lede {
    animation-delay: .12s;
  }

  .hero .signup {
    animation-delay: .24s;
  }

  .spine {
    animation: rise .7s cubic-bezier(.2, .7, .2, 1) both;
    animation-delay: calc(var(--i) * 60ms + .3s);
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
  }
}

/* Accessibility: reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
